lib/koma/cli.rb in koma-0.1.0 vs lib/koma/cli.rb in koma-0.2.0
- old
+ new
@@ -14,18 +14,24 @@
option :identity_file,
type: :string,
banner: '<identity_file>',
desc: 'identity file',
aliases: :i
+ option :port,
+ type: :numeric,
+ banner: '<port>',
+ desc: 'port',
+ aliases: :p
def ssh(host)
user, host = host.split('@') if host.include?('@')
set :backend, :ssh
set :host, host
set :request_pty, true
ssh_options = Net::SSH::Config.for(host)
ssh_options[:user] = user if user
ssh_options[:keys] = [options[:identity_file]] if options[:identity_file]
+ ssh_options[:port] = options[:port] if options[:port]
set :ssh_options, ssh_options
puts JSON.pretty_generate out(options[:key])
end
desc 'exec', 'stdout local inventory'
@@ -60,9 +66,10 @@
key.split(',')
end
keys.each do |k|
begin
out[k] = Specinfra.backend.host_inventory[k]
+ out[k] = Specinfra.backend.host_inventory[k].inspect if k == 'ec2'
rescue NotImplementedError
out[k] = nil
end
end
out