Access to host name in task

292 views
Skip to first unread message

Robin Bowes

unread,
Oct 11, 2010, 5:46:26 AM10/11/10
to capis...@googlegroups.com
Hi,

I know that the run function can get access to the host name using the
$CAPISTRANO:HOST$ variable, eg.

task :peer, :roles => :peer do
# stuff
run "some_command $(LC_ALL=C host $CAPISTRANO:HOST$ | awk '/has
address /{print $4}' | head -n 1)"
end

Is it possible to get access to the same thing within the task itself?

eg. I'd like to do something like:

task :peer, :roles => :peer do
# stuff
require 'resolv'
host_ip = Resolv::DNS.new.getaddress("$CAPISTRANO:HOST$")
run "some_command #{host_ip}"
end

Is that at all possible?

Thanks,

R.
--
"Feed that ego and you starve the soul" - Colonel J.D. Wilkes
http://www.theshackshakers.com/

Lee Hambley

unread,
Oct 11, 2010, 5:50:04 AM10/11/10
to capis...@googlegroups.com
Sorry Robin, not possible for a variety of boring internal reasons, you should maybe consider adding metadata to your server definitions, where you can loop the data you need (the :no_release => true is just arbitrary metadata, for example)

- Lee


--
* You received this message because you are subscribed to the Google Groups "Capistrano" group.
* To post to this group, send email to capis...@googlegroups.com
* To unsubscribe from this group, send email to capistrano+...@googlegroups.com For more options, visit this group at http://groups.google.com/group/capistrano?hl=en

Reply all
Reply to author
Forward
0 new messages