0
votes

I am trying to have Capistrano run a multistage deploy where each stage has multiple servers.

Take, for example, a the first stage of deployment setup with the following roles.

Staging
    Web: "server_a", "server_b"
    DB:  "server_c"

server_a and server_b both deploy_to "/var/www/appname".

server_c needs to deploy_to "/apps/www/appname".

After deployment, Bundler and migrations need to be run, then a restart file set.

  1. Is it possible to deploy to different directories for different servers/roles with Capistrano?
  2. If not, are there any deployment systems out there that can?
  3. If not, am I stuck deploying by hand?
1

1 Answers

0
votes

You can use the Capistrano multi-stage extension and setup a different stage for each environment. You would setup roles for each environment, so staging might use one set of servers for deployment, while production uses another set.

In the same stage-specific recipe (i.e. in config/deploy/staging) you can setup hooks that apply only to that stage. You can also set different values for Capistrano variables there.

For example, you might have stage "staging":

role :web, "server_a", "server_b"
role :db,  "server_c"

set :deploy_to, "/var/www/stagingsite"
after "deploy:update_code" do
    run "echo hello"
end

And in stage "production":

role :web, "server_d", "server_e"
role :db,  "server_f"

set :deploy_to, "/apps/www/appname"
after "deploy:update_code" do
    run "chmod g+w #{release_path}/tmp"
end