Luiz E.
Luiz E.

Reputation: 7279

capistrano doesn't respect port

I'm deploying to production as follow:

HOSTS = [
  'api1.app.io',
  'api2.app.io',
  'api3.app.io',
  'api4.app.io',
  'api5.app.io',
  'api6.app.io',
  'api7.app.io',
  'api8.app.io',
  'api9.app.io',
  'api10.app.io'
].freeze

HOSTS.each do |host|
  server host, roles: %i[app web], user: 'deploy', port: 2323
end

although it fails when capistrano tries to ssh into the servers because it still tries to connect using port 22...

(Backtrace restricted to imported tasks)
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing on host api2.app.io: Net::SSH::ConnectionTimeout

Net::SSH::ConnectionTimeout: Net::SSH::ConnectionTimeout

Errno::ETIMEDOUT: Connection timed out - connect(2) for xx.xx.xx.xx:22

Is there any other way to configure the ports?

Upvotes: 0

Views: 305

Answers (1)

Matt Brictson
Matt Brictson

Reputation: 11102

The :port option should work. If it does not, that it is a bug. Please open a bug report at https://github.com/capistrano/capistrano/issues .

As a workaround, you can also specify the port via the hostname using the <host>:<port> syntax, like this:

HOSTS.each do |host|
  server "#{host}:#{port}", roles: %i[app web], user: 'deploy'
end

Upvotes: 1

Related Questions