# Variable precedence

**URL:** <https://forum.ansible.com/t/variable-precedence/21105>\
**Category:** Ansible Project\
**Created:** [April 8, 2016, 10:29am UTC](https://forum.ansible.com/t/variable-precedence/21105 "2016-04-08T10:29:37Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Michal\_Siska](https://avatars.discourse-cdn.com/v4/letter/m/91b2a8/32.png) [@Michal\_Siska](https://forum.ansible.com/u/Michal_Siska)\
**Post date:** [April 8, 2016, 10:29am UTC](https://forum.ansible.com/t/variable-precedence/21105/1 "2016-04-08T10:29:37Z")

</div>

I’m trying to understand variable precedence in Ansible - more exactly the part about host\_vars and group\_vars in inventory or playbook. My layout looks like this:

```auto
production/
├── inventory (alfa, beta and gamma hosts)
├── group_vars/
│ └── all (foo=1)
└── host_vars/
    └── alfa (foo=2)
playbooks/
├── site.yml (debuging variable foo)
├── group_vars/
│ └── all (foo=10)
└── host_vars/
    └── beta (foo=20)
 

```

So I have three nodes (alfa, beta and gamma) and foo variable. When I start a play I get this result:

```auto
alfa's foo=2
beta's foo=20
gamma's foo=10
 

```

According to [documentation](http://docs.ansible.com/ansible/playbooks_variables.html#variable-precedence-where-should-i-put-a-variable) the precedence should be following:

1. inventory group\_vars
2. inventory host\_vars
3. playbook group\_vars
4. playbook host\_vars

But my result looks like the precedence is following:

1. inventory group\_vars
2. playbook group\_vars
3. inventory host\_vars
4. playbook host\_vars

Did I misunderstand something? Or is it a mistake in documentation? I’m using Ansible 2.0.1. but same is true for 1.9.3.
