Tatva-Artha

meaning of "it"

Defining custom roles/servers in capistrano

without comments

Capistrano works seamlessly for standard deployment where your app is deployed on at most 3 servers, identified as roles: app, web, db. In most cases, these usually point to the same machine where everything is deployed.

set :deploy_host, "192.168.84.70"
role :app, deploy_host
role :web, deploy_host
role :db,  deploy_host, :primary => true

On a recent project, I needed to do some setup on a 4th machine. And so I added a role

set :deploy_host, "192.168.84.70"
role :app, deploy_host
role :web, deploy_host
role :db,  deploy_host, :primary => true
role :asterisk, "asterisk.domain.com"

Soon, I noticed that default rails tasks such as update_code, symlink started attempting to deploy to this new role. I wondered why those tasks weren’t setup to run only on “app” role. There had to be a solution since I am not the first one who would have needed to define a custom role.

A little digging inside capistrano code revealed :o nly and :except options. Most of these default tasks skipped any roles that were defined with option { :no_release => true }.

# <capistrano_gem>/lib/capistrano/recipes/deploy.rb
task :update_code, :except => { :no_release => true } do
end
task :symlink, :except => { :no_release => true } do
end

So, I had to change my role definition to:

role :asterisk, "asterisknow.pathf.com", :no_release => true

Googling a bit revealed that this was introduced in v1.1.9, as described by the author here.

Note to self: Always pay attention to release notes!

[My capistrano version is v2.5.8.]

http://www.tatvartha.com/wp-content/plugins/sociofluid/images/digg_16.png http://www.tatvartha.com/wp-content/plugins/sociofluid/images/reddit_16.png http://www.tatvartha.com/wp-content/plugins/sociofluid/images/stumbleupon_16.png http://www.tatvartha.com/wp-content/plugins/sociofluid/images/delicious_16.png http://www.tatvartha.com/wp-content/plugins/sociofluid/images/google_16.png http://www.tatvartha.com/wp-content/plugins/sociofluid/images/twitter_16.png

No related posts.

Related posts brought to you by Yet Another Related Posts Plugin.

Written by Sharad

September 18th, 2009 at 5:35 pm

Posted in All

Leave a Reply