What exactly is a “role” in Capistrano?

Roles allow you to write capistrano tasks that only apply to certain servers. This really only applies to multi-server deployments. The default roles of “app”, “web”, and “db” are also used internally, so their presence is not optional (AFAIK)

In the sample you provided, there is no functional difference.

The “:primary => true” is an attribute that allows for further granularity in specifying servers in custom tasks.

Here is an example of role specification in a task definition:

task :migrate, :roles => :db, :only => { :primary => true } do
  # ...
end

See the capistrano website @ https://github.com/capistrano/capistrano/wiki/2.x-DSL-Configuration-Roles-Role for a more extensive explanation.

Leave a Comment