Hi all,
I’m having trouble putting variables in the right places. I don’t believe the documentation actually states where Ansible will look for the variables and i have hit and miss some.
Currently using ansible 1.9.2 on CentOS 7.
Tree structure is as follows:
ansible.cfg
hosts
group_vars/
all
host_vars/
hostname1
playbooks/
play1.yml
roles/
role1/
tasks/
main.yml
templates/
template1.j2
…
when i run ansible-playbook playbooks/play1.yml which creates a file from template1.j2, it is giving me an error saying variable is undefined. The variable is defined in host_vars/hostname1 and the hosts file only has hostname1 in it. However if I were to define the same variable in group_vars/all, it works.
I’m wondering if there’s a way to see which file or folder ansible is reading to look for a particular variable.
I previously found out that the group_vars will required to be on the same directory as the hosts file (or whatever you configure the inventory file is). I would assume that the host_vars/ will require to sit on the same level.
Thanks.