1

We have Apache setup chrooted, so we can multiple apache on single directory for multiple httpd instance. I have added all the different groups with the instance name in inventory but their hosts are same.

While I am running tasks on one httpd instance, it takes groups vars of different group even though the hosts are same in all groups.

1

This answer can help: Ansible same host on different groups with group_vars

Try overriding host variables each time it is required with "vars_files":

hosts: {{ group_name }}
vars_files:
 - group_vars/{{ group_name }}.yml
tasks:
0

I have done another workaround.

I have added entries in /etc/hosts with different hostname but with same ips like below.

10.0.0.2 apache1
10.0.0.3 apache2
10.0.0.2 newapache1
10.0.0.3 newapache2

also i have added in inventory like below

[apache]
apache1
apache2

[newapache]
newapache1
newapache2

with same name you can create the groupvars with different details for same server.

Its not correct solution but for small setup its work great.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.