In my fabric scripts I have the following problem. I have a main task called autodeploy. Within this task I have some tasks that I only want to run once, locally. all remote tasks should run on each of the hosts of the host list.
env.roledefs ={
'testing': ['t-server-01', 't-server-02']
'staging': ['s-server-01', 's-server-02']
'live': ['l-server-01', 'l-server-02']
}
def localtask1():
# download artifact
def localtask2():
# cleanup locally
def remotetask():
# deploy artifact to all hosts
def autodeploy():
localtask1() # run this task only once, locally
remotetask() # run this task on all hosts
localtask2() # run this task only once
The call is the following. I want to pass the role as an attribute.
fab -R test autodeploy