I\'ve got this code (foo and bar are local servers):
env.hosts = [\'foo\', \'bar\']
def mytask():
print(env.hosts[0])
<
Use env.host_string. You can find a full list of env variables here.
Thanks Marcelo.
If you want to actually use env.host_string (for concatenation purpose for instance), be sure to be inside a task. Its value is None outside.
You can just do:
env.hosts = ['foo', 'bar']
def mytask():
print(env.host)
Because when you're in the task as executed by fab, you'll have that var set for free.