我们对主机(和linux用户)使用这种模式:
coreapp_customer_stageID@server我想在与模式匹配的主机列表上运行fabric命令。
我想在客户"c1“的核心应用程序"foocms”的所有主机上运行"date“。
我可以用角色,但有很多顾客.一种全球匹配的方式会很好。
发布于 2013-09-19 08:08:29
你可以用这个
@task
def set_hosts(lookup_param):
'''
'''
hosts=get_all_systems() # that needs to be implemented by you.
regex=re.compile('^%s' % lookup_param.replace('*', '.*'))
sub_hosts=[host for host in hosts if regex.match(host)]
if not sub_hosts:
raise ValueError('No host matches %s. Available: %s' % (lookup_param, hosts))
env.hosts = sub_hosts
@task
def date():
run('date')示例:fab set_hosts:coreapp_customer1_* date
摘自:http://docs.fabfile.org/en/1.7/usage/execution.html#the-alternate-approach
https://stackoverflow.com/questions/18889354
复制相似问题