我有這樣一個fabfile如下:Python結構任務可以調用其他任務並尊重它們的主機列表嗎?
@hosts('host1')
def host1_deploy():
"""Some logic that is specific to deploying to host1"""
@hosts('host2')
def host2_deploy():
"""Some logic that is specific to deploying to host2"""
def deploy():
""""Deploy to both hosts, each using its own logic"""
host1_deploy()
host2_deploy()
我願做
fab deploy
,並把它等同於
fab host1_deploy host2_deploy
換句話說,運行各子任務,併爲每個人使用它指定的主機列表。但是,這不起作用。相反,deploy()任務需要它自己的主機列表,它將傳播給它的所有子任務。
有沒有辦法在這裏更新deploy()任務,所以它會做我想要的,同時留下子任務,讓他們可以單獨運行?
不起作用... – 2011-08-14 09:55:34