# Alternative Directory Layout fails to load group\_vars with -i inventories

**URL:** <https://forum.ansible.com/t/alternative-directory-layout-fails-to-load-group-vars-with-i-inventories/24859>\
**Category:** Ansible Project\
**Created:** [June 30, 2017, 10:21am UTC](https://forum.ansible.com/t/alternative-directory-layout-fails-to-load-group-vars-with-i-inventories/24859 "2017-06-30T10:21:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vasco\_Barroso](https://avatars.discourse-cdn.com/v4/letter/v/e5b9ba/32.png) [@Vasco\_Barroso](https://forum.ansible.com/u/Vasco_Barroso)\
**Post date:** [June 30, 2017, 10:21am UTC](https://forum.ansible.com/t/alternative-directory-layout-fails-to-load-group-vars-with-i-inventories/24859/1 "2017-06-30T10:21:10Z")

</div>

Hi,

I’m currently having some issues while using Ansible with the Alternative Directory Layout as defined in the docs.  
Let’s take the following inventory structure (which I like because it allows me to split neatly between different setups):

inventories  
`-- my-setup

> – group\_vars
> 
> > – group1  
> > `-- group2 -- hosts `– host\_vars  
> > `-- [my-server.com](http://my-server.com)

In group\_vars I want to define some variables that override the default values set in the roles.

My problem is the following.

1. This works as expected:

`ansible-playbook -i inventories/my-setup ...`

1. This also works as expected:

`ansible-playbook -i inventories/my-setup/hosts ...`

1. But this fails to apply whatever is defined in inventories/my-setup/group\_vars:

`ansible-playbook -i inventories ...`

This behavior is - at least for me - counter intuitive because ansible still digs up the inventories/my-setup/hosts file but then doesn’t apply group\_vars.  
What I would expect is either apply the group\_vars settings or complain that no inventory has been found.

The situation I want to avoid is that someone executes 3. and inadvertently deploys default values that break running setups.  
Maybe I’m doing something wrong, but so far I fail to see what.

Any ideas ?

Thanks,  
Vasco

---

<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:** [July 3, 2017, 2:21pm UTC](https://forum.ansible.com/t/alternative-directory-layout-fails-to-load-group-vars-with-i-inventories/24859/2 "2017-07-03T14:21:30Z")

</div>

The docs state that these directories must be 'adjacent to the  
inventory file', the problem here is the 'recursive directory' as the  
assumption when using a directory is that the inventory files are  
contained in THAT directory and that any recursion should be added to  
'that file' as a multifile dir.

---

<div class="post-metadata">

**Author:** ![Vasco\_Barroso](https://avatars.discourse-cdn.com/v4/letter/v/e5b9ba/32.png) [@Vasco\_Barroso](https://forum.ansible.com/u/Vasco_Barroso)\
**Post date:** [July 4, 2017, 2:21pm UTC](https://forum.ansible.com/t/alternative-directory-layout-fails-to-load-group-vars-with-i-inventories/24859/3 "2017-07-04T14:21:01Z")

</div>

Thanks for the answer.  
The group\_vars and host\_vars directories are adjacent to the hosts file, so it should work right ?  
Not sure I fully understand your point about ‘recursive directory’.

I’ve finally solved the issue by putting individual inventories in separate top level directories (not under inventories):

`

my-setup-1/

> – group\_vars
> 
> > – group1  
> > `-- group2 -- hosts `– host\_vars  
> > `-- [my-server1.com](http://my-server1.com)

my-setup-2/

> – group\_vars
> 
> > – group1  
> > `-- group2 -- hosts `– host\_vars  
> > `-- [my-server2.com](http://my-server2.com)

`

Still not optimal from my point of view, but does the job.  
Funny thing, running the debug module with -i inventories says “inventory\_file”: null.  
But Ansible still picks up the list of hosts (not the vars) somehow.

Cheers,  
Vasco
