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.trackback
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.
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
Thanks,
Madhu
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.
John
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`