Module: Formatron::S3::ChefServerKeys
- Defined in:
- lib/formatron/s3/chef_server_keys.rb
Overview
manage the Chef Server user and organization keys
Constant Summary collapse
- USER_PEM_NAME =
'user.pem'
- ORGANIZATION_PEM_NAME =
'organization.pem'
Class Method Summary collapse
-
.destroy(aws:, bucket:, name:, target:, guid:) ⇒ Object
rubocop:disable Metrics/MethodLength.
-
.get(aws:, bucket:, name:, target:, guid:, directory:) ⇒ Object
rubocop:disable Metrics/MethodLength rubocop:disable Metrics/ParameterLists.
- .organization_pem_key(name:, target:, guid:) ⇒ Object
- .organization_pem_path(directory:) ⇒ Object
-
.user_pem_key(name:, target:, guid:) ⇒ Object
rubocop:enable Metrics/MethodLength.
- .user_pem_path(directory:) ⇒ Object
Class Method Details
.destroy(aws:, bucket:, name:, target:, guid:) ⇒ Object
rubocop:disable Metrics/MethodLength
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/formatron/s3/chef_server_keys.rb', line 48 def self.destroy( aws:, bucket:, name:, target:, guid: ) user_pem_key = self.user_pem_key name: name, target: target, guid: guid Formatron::LOG.info do 'Delete Chef Server user key from ' \ "#{bucket}/#{user_pem_key}" end aws.delete_file( bucket: bucket, key: user_pem_key ) organization_pem_key = self.organization_pem_key( name: name, target: target, guid: guid ) Formatron::LOG.info do 'Delete Chef Server organization key ' \ "from #{bucket}/#{organization_pem_key}" end aws.delete_file( bucket: bucket, key: organization_pem_key ) end |
.get(aws:, bucket:, name:, target:, guid:, directory:) ⇒ Object
rubocop:disable Metrics/MethodLength rubocop:disable Metrics/ParameterLists
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/formatron/s3/chef_server_keys.rb', line 13 def self.get( aws:, bucket:, name:, target:, guid:, directory: ) user_pem_key = self.user_pem_key name: name, target: target, guid: guid Formatron::LOG.info do 'Download Chef Server user key from ' \ "#{bucket}/#{user_pem_key}" end aws.download_file( bucket: bucket, key: user_pem_key, path: user_pem_path(directory: directory) ) organization_pem_key = self.organization_pem_key( name: name, target: target, guid: guid ) Formatron::LOG.info do 'Download Chef Server organization key ' \ "from #{bucket}/#{organization_pem_key}" end aws.download_file( bucket: bucket, key: organization_pem_key, path: organization_pem_path(directory: directory) ) end |
.organization_pem_key(name:, target:, guid:) ⇒ Object
90 91 92 93 94 95 96 |
# File 'lib/formatron/s3/chef_server_keys.rb', line 90 def self.organization_pem_key(name:, target:, guid:) Path.key( name: name, target: target, sub_key: "#{guid}/#{ORGANIZATION_PEM_NAME}" ) end |
.organization_pem_path(directory:) ⇒ Object
98 99 100 |
# File 'lib/formatron/s3/chef_server_keys.rb', line 98 def self.organization_pem_path(directory:) File.join directory, ORGANIZATION_PEM_NAME end |
.user_pem_key(name:, target:, guid:) ⇒ Object
rubocop:enable Metrics/MethodLength
78 79 80 81 82 83 84 |
# File 'lib/formatron/s3/chef_server_keys.rb', line 78 def self.user_pem_key(name:, target:, guid:) Path.key( name: name, target: target, sub_key: "#{guid}/#{USER_PEM_NAME}" ) end |
.user_pem_path(directory:) ⇒ Object
86 87 88 |
# File 'lib/formatron/s3/chef_server_keys.rb', line 86 def self.user_pem_path(directory:) File.join directory, USER_PEM_NAME end |