# Multiple plays in the same playbook resolve group variables incorrectly

**URL:** <https://forum.ansible.com/t/multiple-plays-in-the-same-playbook-resolve-group-variables-incorrectly/27648>\
**Category:** Ansible Project\
**Created:** [May 28, 2018, 2:55am UTC](https://forum.ansible.com/t/multiple-plays-in-the-same-playbook-resolve-group-variables-incorrectly/27648 "2018-05-28T02:55:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Behrang](https://avatars.discourse-cdn.com/v4/letter/b/ed655f/32.png) [@Behrang](https://forum.ansible.com/u/Behrang)\
**Post date:** [May 28, 2018, 2:55am UTC](https://forum.ansible.com/t/multiple-plays-in-the-same-playbook-resolve-group-variables-incorrectly/27648/1 "2018-05-28T02:55:09Z")

</div>

Source code: [https://github.com/behrangsa/sample-ansible-role](https://github.com/behrangsa/sample-ansible-role)

Background:

I have three different environments: test, staging, and prod and 3 applications that I deploy to them.

In staging and prod, each application have a dedicated server. In test, they all will be deployed to the same box.

The test inventory looks like this:

.  
├── group\_vars  
│ ├── accounting.yml  
│ ├── all.yml  
│ ├── payroll.yml  
│ └── timesheets.yml  
└── hosts

The contents of these files are shown here:

**_hosts_**

[timesheets]  
test.vagrant.local

[payroll]  
test.vagrant.local

[accounting]  
test.vagrant.local

**_all.yml_**

---

<div class="post-metadata">

**Author:** ![Behrang](https://avatars.discourse-cdn.com/v4/letter/b/ed655f/32.png) [@Behrang](https://forum.ansible.com/u/Behrang)\
**Post date:** [May 28, 2018, 4:53am UTC](https://forum.ansible.com/t/multiple-plays-in-the-same-playbook-resolve-group-variables-incorrectly/27648/2 "2018-05-28T04:53:30Z")

</div>

Turned out this was expected behavior. From the [docs](http://docs.ansible.com/ansible/latest/user_guide/intro_inventory.html):

> It is ok to put systems in more than one group, for instance a server could be both a webserver and a dbserver. If you do, note that variables will come from all of the groups they are a member of.

In the meantime, I have worked around it by using play vars/var\_files. For example:
