How to deploy to multiple redundant production servers with "cap deploy"?

Posted by Chad Johnson on Stack Overflow See other posts from Stack Overflow or by Chad Johnson
Published on 2010-06-08T15:39:56Z Indexed on 2010/06/08 15:42 UTC
Read the original article Hit count: 211

Filed under:
|

Capistrano is working great to deploy to a single server. However, I have multiple production API servers for my web application. When I deploy, my code needs to get deployed to every API server at once. Specifying each server manually is NOT the solution I am looking for (e.g. I don't want to do "cap api1 deploy; cap api2 deploy").

Is there a way, using Capistrano, to deploy to all servers at once, with just a simple "cap deploy"? I'm wondering what changes I would need to make to a typical deploy.rb file, whether I'd need to create a separate file for each server, and whether and how the Capfile would need to be changed. Also, I need to be able to specify a different deploy_to path for each server. And ideally, I wouldn't have to repeat things in different config files for different servers (eg. wouldn't have to specify :repository, :application, etc. multiple times).

I have spent hours searching Google on this and looking through tutorials, but I have found nothing helpful.

Here is a snippet from my current deploy.rb file:

set :application, "testapplication" 
set :repository,  "ssh://domain.com//srv/hg/#{application}" 
set :scm, :mercurial

set :deploy_to, "/srv/www/#{application}" 

role :web, "domain.com" 
role :app, "domain.com" 
role :db,  "domain.com", :primary => true, :norelease => true

Should I just use the multistage extension and do this?

task :deploy_everything do
  system "cap api1 deploy" 
  system "cap api2 deploy" 
  system "cap api2 deploy" 
end

That could work, but I feel like this isn't what this extension is meant for...

© Stack Overflow or respective owner

Related posts about deployment

Related posts about capistrano