lib/capistrano/configuration/roles.rb
# Define a new role and its associated servers. You must specify at least
# one host for each role. Also, you can specify additional information
# (in the form of a Hash) which can be used to more uniquely specify the
# subset of servers specified by this specific role definition.
#
# Usage:
#
#   role :db,  "db1.example.com", "db2.example.com"
#   role :db,  "master.example.com", :primary => true
#   role :app, "app1.example.com", "app2.example.com"
#
# You can also encode the username and port number for each host in the
# server string, if needed:
#
#   role :web,  "www@web1.example.com"
#   role :file, "files.example.com:4144"
#   role :db,   "admin@db3.example.com:1234"
#
# Lastly, username and port number may be passed as options, if that is
# preferred; note that the options apply to all servers defined in
# that call to "role":
#
#   role :web, "web2", "web3", :user => "www", :port => 2345
Define a new role and its associated servers. You must specify at least
one host for each role. Also, you can specify additional information
(in the form of a Hash) which can be used to more uniquely specify the
subset of servers specified by this specific role definition.





You can also encode the username and port number for each host in the
server string, if needed.



Lastly, username and port number may be passed as options, if that is
preferred; note that the options apply to all servers defined in
that call to "role".


Define a new role and its associated servers . You must specify at least one host for each role . Also you can specify additional information ( in the form of a Hash ) which can be used to more uniquely specify the subset of servers specified by this specific role definition . You can also encode the username and port number for each host in the server string if needed . Lastly username and port number may be passed as options if that is preferred ; note that the options apply to all servers defined in that call to " role " .
def role(which, *args, &block)
        options = args.last.is_a?(Hash) ? args.pop : {}
        which = which.to_sym
        roles[which] ||= Role.new
        roles[which].push(block, options) if block_given?
        args.each { |host| roles[which] << ServerDefinition.new(host, options) }
      end
def role ( which , * args , & block ) options = args . last . is_a? ( Hash ) ? args . pop : { } which = which . to_sym roles [ which ] ||= Role . new roles [ which ] . push ( block , options ) if block_given? args . each { | host | roles [ which ] << ServerDefinition . new ( host , options ) } end
Define a new role and its associated servers.
Define a new role and its associated servers .
# The roles Hash is defined so that unrecognized keys always auto-initialize # to a new Role instance (see the assignment in the initialize_with_roles method, # above). However, we explicitly assign here so that role declarations will # vivify the role object even if there are no server arguments. (Otherwise, # role(:app) won't actually instantiate a Role object for :app.)
which
<not_specific>
args
<not_specific>
block
<not_specific>