Reputation: 1457
In inventory file, I define two groups, A and B. Also have two separate playbooks to apply host of them.
Meanwhile, define group_vars/A and group_vars/B to hold the variables, but some of them with same name.
By the following document, it says only the last one wins for same name variable.
So how to let Ansible to only use the variables defined in groups/A when play play_book_A?
The other question is, what's the difference between playbook group_vars/* and inventory group_vars/* ?
Upvotes: 1
Views: 1131
Reputation: 9
The difference between playbook group_vars and inventory group_vars is only the precedence. group_vars files in playbook and inventory are merged (i just tested it).
Regarding your problem, if your hosts are not in group A AND group B, everything should work as expected (no overriding between group_vars).
Upvotes: 0