Module: Capistrano::ASG::Rolling::SSH

Defined in:
lib/capistrano/asg/rolling/ssh.rb

Overview

SSH availability test.

Class Method Summary collapse

Class Method Details

.test?(ip_address, user, ssh_options) ⇒ Boolean

Returns:

  • (Boolean)


10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/capistrano/asg/rolling/ssh.rb', line 10

def test?(ip_address, user, ssh_options)
  options = ssh_options || {}
  options[:timeout] = 10

  ::Net::SSH.start(ip_address, user, options) do |ssh|
    ssh.exec!('echo hello')
  end

  true
rescue ::Net::SSH::ConnectionTimeout, ::Net::SSH::Proxy::ConnectError, Errno::ECONNREFUSED, Errno::ETIMEDOUT
  false
end