Class: RakeCloudspin::Tasks::SshKeyTask

Inherits:
BaseTask show all
Defined in:
lib/rake_cloudspin/tasks/ssh_key_task.rb

Instance Method Summary collapse

Methods inherited from BaseTask

#role_user_variable_name, #spin_user_variables, #stack_config

Methods inherited from RakeCloudspin::TaskLib

#check_required, check_required_for, #initialize, parameter, parameter_definitions, #process_arguments, #process_block, #setup_defaults, setup_defaults_for

Constructor Details

This class inherits a constructor from RakeCloudspin::TaskLib

Instance Method Details

#defineObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/rake_cloudspin/tasks/ssh_key_task.rb', line 7

def define
    desc "Ensure ssh keys for #{stack_name}"
    task :ssh_keys do
      ssh_keys_config = stack_config.ssh_keys

      role_param = maybe_role_parameter

      ssh_keys_config.each { |ssh_key_name|
        key = AwsSshKey::Key.new(
          key_path: "/#{stack_config.estate}/#{stack_config.component}/#{stack_name}/#{stack_config.deployment_identifier}/ssh_key",
          key_name: ssh_key_name,
          aws_region: stack_config.region,
          tags: {
            :Estate => stack_config.estate,
            :Component => stack_config.component,
            :Service => stack_name,
            :DeploymentIdentifier => stack_config.deployment_identifier
          },
          **role_param
        )
        key.load
        key.write("work/#{stack_type}/#{stack_name}/ssh_keys/")
      }
    end

    task :plan => [ :ssh_keys ]
    task :provision => [ :ssh_keys ]
end

#maybe_role_parameterObject



36
37
38
39
40
41
42
# File 'lib/rake_cloudspin/tasks/ssh_key_task.rb', line 36

def maybe_role_parameter
  if assume_role? 
    { role: stack_manager_role_arn }
  else
    {}
  end
end