class Itamae::Backend::Ssh
Private Instance Methods
create_specinfra_backend()
click to toggle source
# File lib/itamae/backend.rb, line 217 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], ) end
disable_sudo?()
click to toggle source
# File lib/itamae/backend.rb, line 262 def disable_sudo? !@options[:sudo] end
ssh_options()
click to toggle source
# File lib/itamae/backend.rb, line 227 def ssh_options opts = {} opts[:host_name] = @options[:host] # from ssh-config opts.merge!(Net::SSH::Config.for(@options[:host])) opts[:user] = @options[:user] || opts[:user] || Etc.getlogin 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 %x`#{vagrant_cmd}` end else %x`#{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