Class: Formatron::Chef::Keys

Inherits:
Object
  • Object
show all
Defined in:
lib/formatron/chef/keys.rb

Overview

Download the Chef Server keys

Instance Method Summary collapse

Constructor Details

#initialize(directory:, aws:, bucket:, name:, target:, guid:, ec2_key:) ⇒ Keys

rubocop:disable Metrics/ParameterLists



8
9
10
11
12
13
14
15
16
# File 'lib/formatron/chef/keys.rb', line 8

def initialize(directory:, aws:, bucket:, name:, target:, guid:, ec2_key:)
  @aws = aws
  @bucket = bucket
  @name = name
  @target = target
  @guid = guid
  @ec2_key = ec2_key
  @directory = directory
end

Instance Method Details

#ec2_keyObject



42
43
44
# File 'lib/formatron/chef/keys.rb', line 42

def ec2_key
  File.join @directory, 'ec2_key'
end

#initObject

rubocop:enable Metrics/ParameterLists



19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/formatron/chef/keys.rb', line 19

def init
  S3::ChefServerKeys.get(
    aws: @aws,
    bucket: @bucket,
    name: @name,
    target: @target,
    guid: @guid,
    directory: @directory
  )
  File.write ec2_key, @ec2_key
  File.chmod 0600, ec2_key
end

#organization_keyObject



36
37
38
39
40
# File 'lib/formatron/chef/keys.rb', line 36

def organization_key
  S3::ChefServerKeys.organization_pem_path(
    directory: @directory
  )
end

#user_keyObject



32
33
34
# File 'lib/formatron/chef/keys.rb', line 32

def user_key
  S3::ChefServerKeys.user_pem_path directory: @directory
end