# variable scope groups\_vars  overwrides host\_vars?

**URL:** <https://forum.ansible.com/t/variable-scope-groups-vars-overwrides-host-vars/16838>\
**Category:** Ansible Project\
**Created:** [November 21, 2014, 1:47am UTC](https://forum.ansible.com/t/variable-scope-groups-vars-overwrides-host-vars/16838 "2014-11-21T01:47:11Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Steve\_Kieu](https://avatars.discourse-cdn.com/v4/letter/s/41988e/32.png) [@Steve\_Kieu](https://forum.ansible.com/u/Steve_Kieu)\
**Post date:** [November 21, 2014, 1:47am UTC](https://forum.ansible.com/t/variable-scope-groups-vars-overwrides-host-vars/16838/1 "2014-11-21T01:47:11Z")

</div>

Hi all,

I have read the [http://docs.ansible.com/playbooks\_variables.html#variable-precedence-where-should-i-put-a-variable](http://docs.ansible.com/playbooks_variables.html#variable-precedence-where-should-i-put-a-variable) it does nto answer my question.

Basically I saw two unexpected (at least common sense speaking) behaviour.

example in my inventory hosts file

[base]  
jibs

[base:vars]  
DNS\_SERVER=172.17.42.1

[jibs]  
test-jibs ansible\_ssh\_host=192.168.0.100 ansible\_ssh\_user=root

[jibs:vars]  
XX=VALUE

1. The host test-jibs in jibs groups does not inherit the base:vars

2. If I have a file named test-jibs in the directory host\_vars these variable is not used when the section [jibs:vars] has the same variable name - which is group\_vars has more priority than host\_vars.

Is it correct behaviour or am I wrong somewhere in my setup.

Kind regards

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [November 21, 2014, 1:52am UTC](https://forum.ansible.com/t/variable-scope-groups-vars-overwrides-host-vars/16838/2 "2014-11-21T01:52:44Z")

</div>

I think you want

[base:groups]  
jibs

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [November 21, 2014, 1:56am UTC](https://forum.ansible.com/t/variable-scope-groups-vars-overwrides-host-vars/16838/3 "2014-11-21T01:56:35Z")

</div>

as for the var priority, host\_vars should trump group vars, if that is  
not the case it is a bug.

I just tested with 1.7.2 and current devel and this works as expected.

what versions are you running? (ansible, python, OS)

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [November 21, 2014, 2:00am UTC](https://forum.ansible.com/t/variable-scope-groups-vars-overwrides-host-vars/16838/4 "2014-11-21T02:00:27Z")

</div>

that was meant to be:

[base:children]  
jibs

---

<div class="post-metadata">

**Author:** ![Steve\_Kieu](https://avatars.discourse-cdn.com/v4/letter/s/41988e/32.png) [@Steve\_Kieu](https://forum.ansible.com/u/Steve_Kieu)\
**Post date:** [November 21, 2014, 2:04am UTC](https://forum.ansible.com/t/variable-scope-groups-vars-overwrides-host-vars/16838/5 "2014-11-21T02:04:31Z")

</div>

ansible 1.5.4 on ubuntuy 14.04

---

<div class="post-metadata">

**Author:** ![Steve\_Kieu](https://avatars.discourse-cdn.com/v4/letter/s/41988e/32.png) [@Steve\_Kieu](https://forum.ansible.com/u/Steve_Kieu)\
**Post date:** [November 21, 2014, 2:04am UTC](https://forum.ansible.com/t/variable-scope-groups-vars-overwrides-host-vars/16838/6 "2014-11-21T02:04:57Z")

</div>

Thanks - I will try

---

<div class="post-metadata">

**Author:** ![Steve\_Kieu](https://avatars.discourse-cdn.com/v4/letter/s/41988e/32.png) [@Steve\_Kieu](https://forum.ansible.com/u/Steve_Kieu)\
**Post date:** [November 21, 2014, 3:09am UTC](https://forum.ansible.com/t/variable-scope-groups-vars-overwrides-host-vars/16838/7 "2014-11-21T03:09:10Z")

</div>

Looks like a bug in the version 1.5.2 on Ubuntu. I upgrade it to 1.7.2 and the host vars is correct now.

I also use [base:children] syntax and it seems all good.

Thanks all for suggestions.

Kind regards
