class Rundock::Backend::Ssh

Private Instance Methods

create_specinfra_backend() click to toggle source
# File lib/rundock/backend.rb, line 156
def create_specinfra_backend
  Specinfra::Backend::Ssh.new(
    request_pty: true,
    host: @options[:host_name],
    disable_sudo: !@options[:sudo],
    ssh_options: @options
  )
end
filter_net_ssh_options(options) click to toggle source
# File lib/rundock/backend.rb, line 147
def filter_net_ssh_options(options)
  opts = {}
  options.each do |k, v|
    opts[k] = v if Net::SSH::VALID_OPTIONS.include?(k)
  end

  opts
end
parse(options) click to toggle source
# File lib/rundock/backend.rb, line 121
def parse(options)
  ssh_opts = if options[:ssh_config] && FileTest.exists?(options[:ssh_config])
               Net::SSH::Config.for(options[:host], [options[:ssh_config]])
             else
               Net::SSH::Config.for(options[:host])
             end

  # priority = (cli options > scenario target information section > ssh config)
  ssh_opts[:host_name] = options[:host] unless ssh_opts[:host_name]
  ssh_opts[:keys] = Array(options[:key]) if options[:key]
  ssh_opts[:password] = parse_password_from_stdin if options[:ask_password]
  ssh_opts.merge!(filter_net_ssh_options(options))
  ssh_opts[:proxy] = Kernel.eval(options[:proxy]) if options[:proxy]

  Logger.debug(%(Net::SSH Options: "#{ssh_opts}"))

  ssh_opts
end
parse_password_from_stdin() click to toggle source
# File lib/rundock/backend.rb, line 140
def parse_password_from_stdin
  print 'password: '
  passwd = STDIN.noecho(&:gets).strip
  print "\n"
  passwd
end