# ansible inventory with multiple groups with same host

**URL:** <https://forum.ansible.com/t/ansible-inventory-with-multiple-groups-with-same-host/27350>\
**Category:** Ansible Project\
**Created:** [April 23, 2018, 2:18pm UTC](https://forum.ansible.com/t/ansible-inventory-with-multiple-groups-with-same-host/27350 "2018-04-23T14:18:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![vladciobancai](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/vladciobancai/32/11320_2.png) [@vladciobancai](https://forum.ansible.com/u/vladciobancai)\
**Post date:** [April 23, 2018, 2:18pm UTC](https://forum.ansible.com/t/ansible-inventory-with-multiple-groups-with-same-host/27350/1 "2018-04-23T14:18:59Z")

</div>

Hi,

I have multiple groups in inventory that use the same host. The idea is that on the same hosts we want to install multiple applications, and the name of the applications should be called as a group

- inventories
- staging
- group\_vars
- web.yml
- backend1.yml
- web1.yml
- hosts

The hosts file contains:  
[web]  
host1

[web1]

host1

[backend]  
host1

In group\_vars every yml file contains variables and this variables are used in templates. Every time when I run ansible-playbook I would like to use only on yml file from group\_vars not all of them, for example when I run ansible-playbook for web1, I want to use group\_vars/web1.yml variables not from all files from group\_vars.

The playbook file:

---

<div class="post-metadata">

**Author:** ![vladciobancai](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/vladciobancai/32/11320_2.png) [@vladciobancai](https://forum.ansible.com/u/vladciobancai)\
**Post date:** [April 24, 2018, 11:57am UTC](https://forum.ansible.com/t/ansible-inventory-with-multiple-groups-with-same-host/27350/2 "2018-04-24T11:57:35Z")

</div>

After some research I used this steps from here [https://github.com/ansible/ansible/issues/9065#issuecomment-379246209](https://github.com/ansible/ansible/issues/9065#issuecomment-379246209) . A hateful hack
