class Itamae::Backend::Ssh
Private Instance Methods
create_specinfra_backend()
click to toggle source
# File lib/itamae/backend.rb, line 241 def create_specinfra_backend Specinfra::Backend::Ssh.new( request_pty: true, host: ssh_options[:host_name], disable_sudo: disable_sudo?, ssh_options: ssh_options, shell: @options[:shell], login_shell: @options[:login_shell], ) end
disable_sudo?()
click to toggle source
# File lib/itamae/backend.rb, line 289 def disable_sudo? !@options[:sudo] end
ssh_options()
click to toggle source
# File lib/itamae/backend.rb, line 252 def ssh_options opts = {} opts[:host_name] = @options[:host] # from ssh-config ssh_config_files = @options[:ssh_config] ? [@options[:ssh_config]] : Net::SSH::Config.default_files opts.merge!(Net::SSH::Config.for(@options[:host], ssh_config_files)) opts[:user] = @options[:user] || opts[:user] || Etc.getlogin opts[:password] = @options[:password] if @options[:password] opts[:keys] = [@options[:key]] if @options[:key] opts[:port] = @options[:port] if @options[:port] if @options[:vagrant] config = Tempfile.new('', Dir.tmpdir) hostname = opts[:host_name] || 'default' vagrant_cmd = "vagrant ssh-config #{hostname} > #{config.path}" if defined?(Bundler) Bundler.with_clean_env do `#{vagrant_cmd}` end else `#{vagrant_cmd}` end opts.merge!(Net::SSH::Config.for(hostname, [config.path])) end if @options[:ask_password] print "password: " password = STDIN.noecho(&:gets).strip print "\n" opts.merge!(password: password) end opts end