jump to navigation

Run a Capistrano task on a single server in a given role February 7, 2008

Posted by John Dewey in Capistrano, Code, Command Line, Deployment, Monkey Patch.

There are times I want to run a Capistrano task on a single server, rather than every system in the role. Adding this monkey patch to deploy.rb adds this functionality. To utilize this feature append ‘server=IP_ADDRESS’ to the Cap command. Tasks are defined to run on particular role(s), this feature will target the server inside a particular tasks role. It will not execute a task on an arbitrary server.  CJ Kihlbom filled me in and stated this can be accomplished with `cap deploy HOSTS=IP_ADDRESS`.  See his comments attached to this post.


1. Madhu - February 13, 2008

Hi John ,

Its a great idea … But I tried pasting the pastie in my deploy name and when I use ” Cap deploy server=MY_IP_ADDRESS ” it is not working .

Can you please me some more in -sight of recipe


2. John Dewey - February 25, 2008

Hi Madhu –

If you add the pastie to the top of deploy.rb you should be good. Be sure you specify an IP address or hostname from your roles after the ‘server=’

Hope it all works out.


3. CJ Kihlbom - April 3, 2008

No need to patch, just use `cap deploy HOSTS=IP_ADDRESS` instead. That’s what cap shell does under the hood when you run `on IP_ADDRESS !deploy`

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: