# Debugging Ansible - where is it looking at?

**URL:** <https://forum.ansible.com/t/debugging-ansible-where-is-it-looking-at/19377>\
**Category:** Ansible Project\
**Created:** [September 29, 2015, 1:21pm UTC](https://forum.ansible.com/t/debugging-ansible-where-is-it-looking-at/19377 "2015-09-29T13:21:30Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jason\_Chia](https://avatars.discourse-cdn.com/v4/letter/j/e8c25b/32.png) [@Jason\_Chia](https://forum.ansible.com/u/Jason_Chia)\
**Post date:** [September 29, 2015, 1:21pm UTC](https://forum.ansible.com/t/debugging-ansible-where-is-it-looking-at/19377/1 "2015-09-29T13:21:30Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Jason\_Chia](https://avatars.discourse-cdn.com/v4/letter/j/e8c25b/32.png) [@Jason\_Chia](https://forum.ansible.com/u/Jason_Chia)\
**Post date:** [September 30, 2015, 12:55am UTC](https://forum.ansible.com/t/debugging-ansible-where-is-it-looking-at/19377/2 "2015-09-30T00:55:02Z")

</div>

seems like i forgot to ask the questions, silly me (it was written quite late after a long day at work).

Question 1: Is it possible to get Ansible to report where it is looking at for a variable? -vvvv switch doesn’t provide any additional information. is there a log i can look at?

Question 2: Do you have an idea why my template isn’t looking at the host\_vars/hostname1 for the variable but have no issues if i were to define the same variable in group\_vars/all?

Thanks.

---

<div class="post-metadata">

**Author:** ![Jason\_Chia](https://avatars.discourse-cdn.com/v4/letter/j/e8c25b/32.png) [@Jason\_Chia](https://forum.ansible.com/u/Jason_Chia)\
**Post date:** [September 30, 2015, 5:16am UTC](https://forum.ansible.com/t/debugging-ansible-where-is-it-looking-at/19377/3 "2015-09-30T05:16:39Z")

</div>

Found the answer for Question 2, the mistake was on me with my play pointing the host as localhost.

As for Question 1, it would still be good to have Ansible report back where it is trying to look.

Thanks.

---

<div class="post-metadata">

**Author:** ![Victor\_Volle](https://avatars.discourse-cdn.com/v4/letter/v/e8c25b/32.png) [@Victor\_Volle](https://forum.ansible.com/u/Victor_Volle)\
**Post date:** [October 1, 2015, 6:20pm UTC](https://forum.ansible.com/t/debugging-ansible-where-is-it-looking-at/19377/4 "2015-10-01T18:20:46Z")

</div>

Hi Jason!

No there is currently no simple switch to get a dump of variables with their “source”.
