# variable precedence - doc possibly wrong

**URL:** <https://forum.ansible.com/t/variable-precedence-doc-possibly-wrong/21053>\
**Category:** Ansible Developer\
**Created:** [April 3, 2016, 5:47pm UTC](https://forum.ansible.com/t/variable-precedence-doc-possibly-wrong/21053 "2016-04-03T17:47:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Brano\_Zarnovican](https://avatars.discourse-cdn.com/v4/letter/b/54ee81/32.png) [@Brano\_Zarnovican](https://forum.ansible.com/u/Brano_Zarnovican)\
**Post date:** [April 3, 2016, 5:47pm UTC](https://forum.ansible.com/t/variable-precedence-doc-possibly-wrong/21053/1 "2016-04-03T17:47:09Z")

</div>

Hi,

I have moved my inventory to “env/dev1/” and found that actual variable precedence is not what the doc says.  
Here is the order of precedence I’m seeing on Ansible 2.0.0.2

env  
└── dev1  
├── ec2.ini  
├── ec2.py  
├── group\_vars  
│ ├── all.yaml (6)  
│ └── group.yaml (4)  
└── host\_vars  
└── host.yaml (2)  
group\_vars  
├── all.yaml (5)  
└── group.yaml (3)

host\_vars  
└── host.yaml (1)  
playbook1.yaml

The documentation specify precedence as

> inventory group\_vars  
> inventory host\_vars  
> playbook group\_vars  
> playbook host\_vars

I would say, there are two issues there:

1. inventory and playbook var precedence is “interwined”
2. it does not mention special handling for group “all”

Here is how it probably should be (from lower to higher precedence):

- inventory group\_vars/all

- playbook group\_vars/all

- inventory group\_vars/

- playbook group\_vars/

- inventory host\_vars

- playbook host\_vars

Do you want me to report an issue for code or documentation ?  
(or explain that both are correct and it’s me who is confused)

Regards,

Brano Zarnovican

---

<div class="post-metadata">

**Author:** ![James\_Cammarata](https://avatars.discourse-cdn.com/v4/letter/j/7c8e57/32.png) [@James\_Cammarata](https://forum.ansible.com/u/James_Cammarata)\
**Post date:** [April 4, 2016, 7:08pm UTC](https://forum.ansible.com/t/variable-precedence-doc-possibly-wrong/21053/2 "2016-04-04T19:08:05Z")

</div>

Could you please open an issue for this with a full working example? I believe I see what you’re talking about, but having something to test against would be useful in testing and validating.

Thanks!

---

<div class="post-metadata">

**Author:** ![Brano\_Zarnovican](https://avatars.discourse-cdn.com/v4/letter/b/54ee81/32.png) [@Brano\_Zarnovican](https://forum.ansible.com/u/Brano_Zarnovican)\
**Post date:** [April 5, 2016, 6:26am UTC](https://forum.ansible.com/t/variable-precedence-doc-possibly-wrong/21053/3 "2016-04-05T06:26:59Z")

</div>

Done.  
[https://github.com/ansible/ansible/issues/15278](https://github.com/ansible/ansible/issues/15278)
