You can get a list of all servers in a role like this:

  servers = roles[:testtct].servers

That'll return an array of Capistrano::ServerDefinition objects. To get
the host name of a single server object, just do "server.host", e.g.:

  puts "servers in testtct role:"
  roles[:testtct].servers.each do |server|
    puts "* #{server.host}"
  end

However, what you REALLY want, is probably just to substitute the name
of the current server in the command, like so:

  run "touch /tmp/$CAPISTRANO:HOST$"

Capistrano will always look for $CAPISTRANO:HOST$ in the command string,
and will replace it with the server's hostname at execution time.

- Jamis

On 1/21/09 10:08 AM, Gerhardus Geldenhuis wrote:
> Hi
> Is there a variable that I can access to get the name of each server
> in the role?
> 
> I want to do something like the following:
> 
> task :idfile, :roles => :testtct do
>   run "touch /tmp/#{testtct.name}"
> end
> 
> Regards
> 
> 
> > 


--~--~---------~--~----~------------~-------~--~----~
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at http://groups.google.com/group/capistrano
-~----------~----~----~----~------~----~------~--~---

Reply via email to