# Feature request --show-vars-path?

**URL:** <https://forum.ansible.com/t/feature-request-show-vars-path/19210>\
**Category:** Ansible Developer\
**Created:** [September 9, 2015, 12:10am UTC](https://forum.ansible.com/t/feature-request-show-vars-path/19210 "2015-09-09T00:10:45Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bob\_Tanner](https://avatars.discourse-cdn.com/v4/letter/b/49beb7/32.png) [@Bob\_Tanner](https://forum.ansible.com/u/Bob_Tanner)\
**Post date:** [September 9, 2015, 12:10am UTC](https://forum.ansible.com/t/feature-request-show-vars-path/19210/1 "2015-09-09T00:10:45Z")

</div>

The location of the group\_vars and host\_vars directories has a tendency to bite me and my team.

We recently moved to using vagrant/virtualbox and vagrant/fusion for testing and we specify a playbook like this:

config.vm.provision “ansible”, type: “ansible” do |ansible|  
config.ssh.username = “vagrant”  
config.ssh.forward\_agent = true  
config.ssh.insert\_key = false  
ansible.playbook = “…/playbooks/dns-server.yml”  
end

A tree of my directory layout.

.  
├── ansible  
├── bin  
├── include  
├── lib  
├── man  
├── playbooks  
└── vagrant

If I’m in the vagrant directory and given the ansible.playbook above (“…/playbooks/dns-server.yml”) where does ansible look for the group\_vars and host\_vars directories?

Here?

vagrant/group\_vars  
vagrant/host\_vars

Here?

playbooks/group\_vars  
playbooks/host\_vars

Can the path for the “vars” be set explicitly? Or a set of directories be appended to the system defaults?

I would find an “ansible --show-vars-path” extremely helpful.

I think I’m missing something simple. Could someone point me to the documentation that explains how ansible searches for the group\_vars and host\_vars directories?

Thanks.

---

<div class="post-metadata">

**Author:** ![sivel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sivel/32/1198_2.png) [@sivel](https://forum.ansible.com/u/sivel)\
**Post date:** [September 9, 2015, 12:28am UTC](https://forum.ansible.com/t/feature-request-show-vars-path/19210/2 "2015-09-09T00:28:21Z")

</div>

[http://docs.ansible.com/ansible/intro\_inventory.html](http://docs.ansible.com/ansible/intro_inventory.html)

Tip: In Ansible 1.2 or later the group\_vars/ and host\_vars/ directories can exist in either the playbook directory OR the inventory directory. If both paths exist, variables in the playbook directory will override variables set in the inventory directory.

---

<div class="post-metadata">

**Author:** ![esco\_real](https://avatars.discourse-cdn.com/v4/letter/e/c89c15/32.png) [@esco\_real](https://forum.ansible.com/u/esco_real)\
**Post date:** [September 9, 2015, 11:05pm UTC](https://forum.ansible.com/t/feature-request-show-vars-path/19210/3 "2015-09-09T23:05:31Z")

</div>

or just strace?

example:

`strace ansible -m debug all 2>&1 | grep _vars`

esco

---

<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:** [September 11, 2015, 12:36am UTC](https://forum.ansible.com/t/feature-request-show-vars-path/19210/4 "2015-09-11T00:36:35Z")

</div>

It will look first to the inventory adjacent group/host\_vars and then  
to the play adjacent group/host\_vars.

Not sure how vagrant/ fits into this picture.

---

<div class="post-metadata">

**Author:** ![Gerard\_Lynch](https://avatars.discourse-cdn.com/v4/letter/g/958977/32.png) [@Gerard\_Lynch](https://forum.ansible.com/u/Gerard_Lynch)\
**Post date:** [September 11, 2015, 5:12pm UTC](https://forum.ansible.com/t/feature-request-show-vars-path/19210/5 "2015-09-11T17:12:54Z")

</div>

I feel the pain, and was in fact just now wishing for explicit path variables to set them. As the others mentioned, the group/host\_vars can be relative to either inventory or playbook - I don’t want to place them relative to playbooks at present.

I originally had a static inventory file, but that bit me, because hosts wouldn’t always be up but ansible was trying to iterate whatever was in groups.

The setup I’ve currently got is, using the provisioner…

$ tree inv  
inv  
├── dev\_aws  
│ ├── ec2.ini  
│ ├── ec2.py  
│ ├── group\_vars → …/group\_vars  
│ ├── host\_vars → …/host\_vars  
│ └── hosts  
├── dev\_vagrant  
│ ├── group\_vars → …/group\_vars  
│ ├── host\_vars → …/host\_vars  
│ └── hosts → …/…/.vagrant/provisioners/ansible/inventory/vagrant\_ansible\_inventory

and

$ tree .vagrant  
…  
└── provisioners  
└── ansible  
└── inventory  
├── group\_vars → …/…/…/…/inv/group\_vars  
├── host\_vars → …/…/…/…/inv/host\_vars

the symlinks are all in my git repo.

hope that gives some idea towards a solution.

---

<div class="post-metadata">

**Author:** ![Yannig\_Perre](https://avatars.discourse-cdn.com/v4/letter/y/5fc32e/32.png) [@Yannig\_Perre](https://forum.ansible.com/u/Yannig_Perre)\
**Post date:** [October 5, 2015, 11:19am UTC](https://forum.ansible.com/t/feature-request-show-vars-path/19210/6 "2015-10-05T11:19:34Z")

</div>

Hi,

I have written a small PR that add the capability to Ansible to add directories in current context. You can have a look here: [https://github.com/ansible/ansible/pull/12628](https://github.com/ansible/ansible/pull/12628)

Basically, you get a new --parent-inventory option (or -p for short version) that let you specify additional group/host\_vars directories (the option append each directories specified).

Maybe we can add this options you are talking about (–show-vars-path and something like --set-vars-path).

Regards,

Yannig
