简体   繁体   English

--hosts是否不会覆盖fabfile本身定义的env.hosts?

[英]Does --hosts not override env.hosts defined within the fabfile itself?

If I have: env.hosts = ['my.host.a', 'my.host.b', 'my.host.c'] , does calling the script with fab -H my.host.a not override what's defined in the fabfile? 如果我有: env.hosts = ['my.host.a', 'my.host.b', 'my.host.c'] ,确实使用fab -H my.host.a调用脚本不会覆盖什么在fabfile中定义?

I set env.hosts as a global at the top of my fabfile. 我在env.hosts的顶部将env.hosts设置为全局变量。 When I pass in -H , my tasks are still executed on the full list. 当我传递-H ,我的任务仍然在完整列表上执行。

The documentation says that the assignment in the fabfile takes precedence. 文档说fabfile中的分配优先。

$ fab -H host1,host2 mytask

Such an invocation is directly equivalent to env.hosts = ['host1', 'host2'] 这样的调用直接等效于env.hosts = ['host1', 'host2']

[...] [...]

It is important to know that these command-line switches are interpreted before your fabfile is loaded: any reassignment to env.hosts or env.roles in your fabfile will overwrite them. 重要的是要知道加载fabfile 之前会解释这些命令行开关:对env.hostsenv.roles任何重新分配都将覆盖它们。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM