Class: Opsicle::SSHCleanKeys
- Inherits:
-
Object
- Object
- Opsicle::SSHCleanKeys
- Defined in:
- lib/opsicle/commands/ssh_clean_keys.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
Instance Method Summary collapse
- #execute(options = {}) ⇒ Object
-
#initialize(environment) ⇒ SSHCleanKeys
constructor
A new instance of SSHCleanKeys.
- #instances ⇒ Object
Constructor Details
#initialize(environment) ⇒ SSHCleanKeys
Returns a new instance of SSHCleanKeys.
5 6 7 |
# File 'lib/opsicle/commands/ssh_clean_keys.rb', line 5 def initialize(environment) @client = Client.new(environment) end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
3 4 5 |
# File 'lib/opsicle/commands/ssh_clean_keys.rb', line 3 def client @client end |
Instance Method Details
#execute(options = {}) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/opsicle/commands/ssh_clean_keys.rb', line 9 def execute(={}) instances.each do |instance| # Fun note: public_dns will be for the elastic ip (if elastic_ip?) host_keys = [:elastic_ip, :public_ip, :public_dns] hosts = host_keys.map { |key| instance[key] } hosts = hosts.reject { |i| i.nil? } hosts.uniq.each do |host| # Is this properly escaped against expansion? command = "ssh-keygen -R #{host}" Output.say_verbose "Executing: #{command}" system(command) end end end |
#instances ⇒ Object
24 25 26 |
# File 'lib/opsicle/commands/ssh_clean_keys.rb', line 24 def instances client.api_call(:describe_instances, { stack_id: client.config.opsworks_config[:stack_id] })[:instances] end |