I've got a task that needs to know which server it's currently being
executed on. Is there a variable containing this value that the task
can get at? e.g.,
task :foobar, :roles => app do
echo "I'm running on the server #{fetch(:something)}"
end
I could get this info by parsing out `hostname` or something, but was
hoping to avoid that... is there a "current_session" or something?
Thanks,
tom
1. You simply want the host name to appear somewhere in a command
you're running in the current task:
run "echo server is $CAPISTRANO:HOST$"
The $CAPISTRANO:HOST$ text gets replaced with the actual hostname
immediately before the command is executed on each server.
2. You want to know which servers a task is restricted to:
servers = find_servers_for_task(current_task)
puts "servers: #{servers.join(', ')}"
Hope that helps,
Jamis
> --~--~---------~--~----~------------~-------~--~----~
> To unsubscribe from this group, send email to capistrano-...@googlegroups.com
> For more options, visit this group at http://groups.google.com/group/capistrano
> -~----------~----~----~----~------~----~------~--~---
>
Perfect! I was reading through command.rb but was just looking in
open_channels and glazed right over that call to replace_placeholders.
Thanks much!
Yours,
Tom