# Ansible is ignoring my group vars, hoping I'm doing something obviously wrong...

**URL:** <https://forum.ansible.com/t/ansible-is-ignoring-my-group-vars-hoping-im-doing-something-obviously-wrong/32898>\
**Category:** Ansible Project\
**Tags:** gcp\
**Created:** [May 9, 2020, 11:32pm UTC](https://forum.ansible.com/t/ansible-is-ignoring-my-group-vars-hoping-im-doing-something-obviously-wrong/32898 "2020-05-09T23:32:49Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![David\_Sudia](https://avatars.discourse-cdn.com/v4/letter/d/9fc348/32.png) [@David\_Sudia](https://forum.ansible.com/u/David_Sudia)\
**Post date:** [May 9, 2020, 11:32pm UTC](https://forum.ansible.com/t/ansible-is-ignoring-my-group-vars-hoping-im-doing-something-obviously-wrong/32898/1 "2020-05-09T23:32:49Z")

</div>

Here is my directory structure:

`  
dba.yml (a playbook)  
inventory/  
union.gcp.yml (a dynamic gcp inventory)  
group\_vars/  
all/  
vars.yml  
vault.yml  
dba/  
vars.yml  
roles/  
someroleshere/

`

The command I’m running is  
`$ ansible-playbook -i inventory --vault-password-file=/path/to/file dba.yml`

Ansible reads my inventory just fine and connects to correct VM. The first variable it wants is  
`disks`

which is an array of dicts to format and mount.

Whether I put disks in the dba/vars.yml (the correct place for it to be) or all/vars.yml, Ansible gets to that variable and says it’s undefined.

I have this big messy Ansible repo where everything works but it’s a mess, that I’m starting fresh on because I read back through the docs and realized I wasn’t following any best practices, and now I’m trying to follow them to the letter and can’t get it to work.

Any help appreciated, thanks!

---

<div class="post-metadata">

**Author:** ![vbotka](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/vbotka/32/359_2.png) [@vbotka](https://forum.ansible.com/u/vbotka)\
**Post date:** [May 10, 2020, 2:54am UTC](https://forum.ansible.com/t/ansible-is-ignoring-my-group-vars-hoping-im-doing-something-obviously-wrong/32898/2 "2020-05-10T02:54:24Z")

</div>

> dba.yml (a playbook)  
> inventory/  
> &nbsp;&nbsp;union.gcp.yml (a dynamic gcp inventory)  
> &nbsp;&nbsp;group\_vars/  
> &nbsp;&nbsp;&nbsp;&nbsp;all/  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;vars.yml  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;vault.yml  
> &nbsp;&nbsp;&nbsp;&nbsp;dba/  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;vars.yml  
> roles/  
> &nbsp;&nbsp;someroleshere/
> 
> $ ansible-playbook -i inventory --vault-password-file=/path/to/file dba.yml
> 
> Whether I put disks in the dba/vars.yml (the correct place for it to be) or  
> all/vars.yml, Ansible gets to that variable and says it's undefined.

There is nothing wrong with this

&nbsp;&nbsp;\> cat group\_vars/dba/vars.yml  
&nbsp;&nbsp;disks: var from group\_vars/dba/vars.yml

&nbsp;&nbsp;\> cat inventory/hosts  
&nbsp;&nbsp;[dba]  
&nbsp;&nbsp;test\_01  
&nbsp;&nbsp;test\_02  
&nbsp;&nbsp;test\_03

&nbsp;&nbsp;\> cat dba.yml  
&nbsp;&nbsp;- hosts: dba  
&nbsp;&nbsp;&nbsp;&nbsp;tasks:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- debug:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var: disks

&nbsp;&nbsp;\> ansible-playbook -i inventory/hosts dba.yml

&nbsp;&nbsp;PLAY [dba] \*\*\*\*\*\*\*\*\*\*

&nbsp;&nbsp;TASK [debug] \*\*\*\*\*\*\*\*  
&nbsp;&nbsp;ok: [test\_02] =\> {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"disks": "var from group\_vars/dba/vars.yml"  
&nbsp;&nbsp;}  
&nbsp;&nbsp;ok: [test\_01] =\> {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"disks": "var from group\_vars/dba/vars.yml"  
&nbsp;&nbsp;}  
&nbsp;&nbsp;ok: [test\_03] =\> {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"disks": "var from group\_vars/dba/vars.yml"  
&nbsp;&nbsp;}

---

<div class="post-metadata">

**Author:** ![David\_Sudia](https://avatars.discourse-cdn.com/v4/letter/d/9fc348/32.png) [@David\_Sudia](https://forum.ansible.com/u/David_Sudia)\
**Post date:** [May 10, 2020, 6:21pm UTC](https://forum.ansible.com/t/ansible-is-ignoring-my-group-vars-hoping-im-doing-something-obviously-wrong/32898/3 "2020-05-10T18:21:18Z")

</div>

Hello Vladimir, thank you for the response!

My understanding was that group\_vars needed to be in the same directory as the inventory to work, but in your example it looks like group\_vars is one directory up, is that correct?

---

<div class="post-metadata">

**Author:** ![vbotka](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/vbotka/32/359_2.png) [@vbotka](https://forum.ansible.com/u/vbotka)\
**Post date:** [May 10, 2020, 7:31pm UTC](https://forum.ansible.com/t/ansible-is-ignoring-my-group-vars-hoping-im-doing-something-obviously-wrong/32898/4 "2020-05-10T19:31:32Z")

</div>

Hi David,

---

<div class="post-metadata">

**Author:** ![David\_Sudia](https://avatars.discourse-cdn.com/v4/letter/d/9fc348/32.png) [@David\_Sudia](https://forum.ansible.com/u/David_Sudia)\
**Post date:** [May 11, 2020, 5:17pm UTC](https://forum.ansible.com/t/ansible-is-ignoring-my-group-vars-hoping-im-doing-something-obviously-wrong/32898/5 "2020-05-11T17:17:32Z")

</div>

To close this out, I realized from your example that in my debug statements I was putting the var in “{{}}”, which was giving me bad info and making it look like the var was undefined. Once I took it out of the quotes/curlies, I saw that the var I was trying to use was being overridden by a var provided by my host.

So thank you for the help! Problem solved!
