I'm trying to change hosts on a per-task basis. Here's my code:
@task
def process():
execute(get_file)
execute(transfer_file)
@task
def get_file():
env.hosts = [hexi_host]
This is really the only relevant bit of code. Basically, I'm not defining env.hosts anywhere outside of the get_file task. When I run the script I get:
No hosts found. Please specify (single) host string for connection:
Even though I'm defining it in get_file. If I define it prior to process, it will work, but then I can never change to a different host at a later time. Hope this makes sense, any help is greatly appreciated.
You have to set host before you call execute() function.
See also: http://docs.fabfile.org/en/1.10/api/core/decorators.html