When you have a complex recipe setup with multistage deployment you may run into this error:
`role_list_from': unknown role `something' (ArgumentError)
Consider this task definition:
namespace :foo do
task :bar, :roles => :something do
# do crazy stuff
end
end
Whenever we call foo.bar
in our recipe, Capistrano will fail if you deploy to a stage where none of the servers has the role the error complains about, "something
" in this case.
However, you can hack around it Show archive.org snapshot :
-
Put a
roles[:something]
into yourdeploy.rb
to avoid the above error message.\
Now, when Capistrano enters a hook and tries to call a method that is only available for that group of servers, you'll get another error:`foo.bar' is only run for servers matching {:roles=>:something}, but no servers matched
-
To properly fix it, you also need to avoid running any commands inside that task if no server matches the task's role:
roles[:something] # To make Capistrano aware of it # ... namespace :foo do task :bar, :roles => :something do next if find_servers_for_task(current_task).empty? # Skip for certain setups # do crazy stuff end end
As always, remember to properly hook.
Posted by Arne Hartherz to makandra dev (2011-12-02 15:38)