I want to run different command on the different pc group. my fabric file like following:
env.hosts = ['125.221.225.31','125.221.225.36','125.221.225.33','125.221.225.34','125.221.225.35']
env.roledefs = {
'master':['125.221.225.31'],
'slave':['125.221.225.33','125.221.225.34','125.221.225.35','125.221.225.36']}
@roles('master')
def get_last_hosts():
with cd('/etc'):
get('hosts','/tmp/hosts')
@roles('slave')
def upload_hosts():
with lcd('/tmp'):
put('hosts','/etc/hosts',use_sudo=True)
def update_hosts():
get_last_hosts()
upload_hosts()
I can run:
fab get_last_hosts,
and then run:
fab upload_hosts
I want to merge these steps to one step, so to say:
update_hosts
but that won't work, it will run update_hosts
on every pc in the env.hosts, that's not what I desire.