`
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.
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?
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.