class Opsicle::SSHCleanKeys

Attributes

client[R]

Public Class Methods

new(environment) click to toggle source
# File lib/opsicle/commands/ssh_clean_keys.rb, line 5
def initialize(environment)
  @client = Client.new(environment)
end

Public Instance Methods

execute(options={}) click to toggle source
# File lib/opsicle/commands/ssh_clean_keys.rb, line 9
def execute(options={})
  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() click to toggle source
# 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