I’ve been knee deep in capistrano lately, and I’ve come across in interesting behavior:
Say you have the following:
123456789101112131415
role :app, "app"role :web, "web"task :run_on_web, :roles => :webdo do_something_on_serverendtask :run_on_app, :roles => :appdo do_something_on_serverendtask :do_something_on_serverdo run "/usr/sbin/something"end
If you run the run_on_web task, it will execute the do_something_on_server task using all roles. This isn’t the behavior you most expected most likely. The secret to making this work is to set ENV[‘HOSTS’] match your the set of hosts you are interested in. After you are done you’ll want to set ENV[‘HOSTS’] hosts back to it’s original contents. I’ve whipped up a quick method to make this even easier.