MrDuk
MrDuk

Reputation: 18342

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?

I set env.hosts as a global at the top of my fabfile. When I pass in -H, my tasks are still executed on the full list.

Upvotes: 0

Views: 60

Answers (1)

Chris Martin
Chris Martin

Reputation: 30756

The documentation says that the assignment in the fabfile takes precedence.

$ 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.

Upvotes: 1

Related Questions