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.


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 }}
 - group_vars/{{ group_name }}.yml

I have done another workaround.

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

also i have added in inventory like below



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.