howto use multiple environments with multiple groups?

37 views
Skip to first unread message

Tristan van Bokkem

unread,
Nov 12, 2014, 11:20:52 AM11/12/14
to ansible...@googlegroups.com
Hi,

As explained here http://docs.ansible.com/intro_inventory.html#splitting-out-host-and-group-specific-data we are using multiple environments (acceptance / production) with ansible-playbooks and have set it up as follow:

deploy.yml
inventory
|_ inventory-production
|_inventory-acceptance
group_vars/
|_ acceptance/group1
|_ acceptance/group2
|_ production/group1
|_ production/group2
host_vars/
|_ host1.accept
|_ host2.accept
|_ host1.prod
|_ host2.prod
...

We have for instance some iptables vars defined in group1 and group2. Each specific for their group of hosts.
Now when we run the ansible playbook deploy.yml together with the inventory-production inventory it soon start to work on a host in group1. It will run the tasks for the iptables role and the taks will need vars from the group_vars directory. However it seems it is using the vars that has been combined of both groups and it will use the vars which are alphabetical last. Which in this case is group2. So it is using the wrong vars.

Any idea why this is going wrong?

Michael DeHaan

unread,
Nov 17, 2014, 4:24:26 PM11/17/14
to ansible...@googlegroups.com
This is a common misconception.

All groups that a host are in apply to the host during a run.

This is because groups may imply physical location, purpose, hardware type, and more, while you may only be selecting them by say, purpose.



--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/b25c4dd2-04dd-4779-848e-f1482ec77214%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages