--hosts 不会覆盖 fabfile 本身中定义的 env.hosts 吗?

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

如果我有:env.hosts = ['my.host.a', 'my.host.b', 'my.host.c'],使用 fab -H my.host.a 调用脚本不会覆盖 fabfile 中定义的内容吗?

我将 env.hosts 设置为我的 fabfile 顶部的全局变量。当我传入 -H 时,我的任务仍然在完整列表上执行。

The documentation 表示 fabfile 中的赋值优先。

$ fab -H host1,host2 mytask

Such an invocation is directly equivalent to 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.