Alternative Directory Layout fails to load group_vars with -i inventories

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

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

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.

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

my-setup-2/

– group_vars

– group1
-- group2 -- hosts – host_vars
`-- 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