ansible inventory with multiple groups with same host

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:

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