Possible bug with multiple server set up

18 views
Skip to first unread message

Steve Kenworthy

unread,
Oct 2, 2015, 7:02:16 AM10/2/15
to Capistrano
Versions:
  • Ruby 2.2.2
  • Capistrano 3.4.0
  • Rake 10.4.2
Platform:
  • Working on linux
  • Deploying to linux (on Azure - important, see later)
Files: deploy/production.rb

    server 'example-service.cloudapp.net', user: 'deploy', roles: %w{web app db}, primary: true
    server 'example-service.cloudapp.net:12345', user: 'deploy', roles: %w{web app db}

I have a production.rb file with the above configuration. However, capistrano will only deploy to the 2nd server (on port 12345). It seems unable to detect that I have 2 separate servers which are distinguished by port alone.

Why would I want to do that anyway? I'm deploying to a service hosted on Azure. It's two linux servers load-balanced under a service called "example-service.cloudapp.net". I've opened firewall pinholes for ssh ports for both servers (22 and 12345) so I need to be able to distinguish between 2 separate servers solely by the fact they run under different ports.

I'm guessing I'm doing it wrong and there might be a better way to define the servers. Would anyone be able to suggest an alternative? Thanks in advance.

And yes, I can ssh into each box using the hostnames and ports above. This is more about capistrano being able to see there are two separate servers.

Lee Hambley

unread,
Oct 2, 2015, 7:07:32 AM10/2/15
to Capistrano
I have a production.rb file with the above configuration. However, capistrano will only deploy to the 2nd server (on port 12345). It seems unable to detect that I have 2 separate servers which are distinguished by port alone.

We have had pull request left and right for changing the behaviour of matching hosts for equality, including or excluding ports, usernames, and other properties, it seems unfortunatley there's no happy medium.

The canonical solution is to use a project local `./.ssh/config` to write two host configs (SSHKit, and thus Capistrano will pick that file up and apply it over anything it finds in your `~/.ssh/config`, and write two hosts example_service_server_one example_service_server_two, and refer to those in Capistrano, and add their properties in the project local ssh config.

Give it a try (it's documented in SSHKit, and Capistrano I believe) and let me know how you get on.

--
You received this message because you are subscribed to the Google Groups "Capistrano" group.
To unsubscribe from this group and stop receiving emails from it, send an email to capistrano+...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/capistrano/dc5ea8ae-71f9-40f9-8aa5-032ff20b34a1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Steve Kenworthy

unread,
Oct 10, 2015, 12:12:14 AM10/10/15
to Capistrano
Thanks for your advice, Lee. I didn't know about project local .ssh/config files - excellent.

For anyone else reading this thread, it's documented here: https://github.com/capistrano/sshkit#tunneling-and-other-related-ssh-themes

Regards,
Steve
Reply all
Reply to author
Forward
0 new messages