Path to group_vars etc. when inventory is a directory

Hi,

I have the following setup:

.../group_vars/all.yml etc
.../hosts/static <- an ini file
.../hosts/database <- a script

ansible-playbook -i .../hosts (v1.2, didn't try 1.3 yet in this scenario) fails to find the group_vars directory, because it looks for .../hosts/group_vars/ instead. I understand this is consistent with the rule "look in the directory containing the hosts file" but is this really the desired behaviour? Shouldn't the rule be "directory containing whatever the user specified as inventory"? Would be much more straightforward IMHO.

Best regards,
  Grzegorz Nosek

Yep, this is intended behavior as this allows you to individually select inventory inside the directory or the whole of all of them without moving your group_vars and host_vars files.

Hmm, OK.

So when I migrate from a single-file inventory to a split one, my paths change from:

…/hosts
…/host_vars/

to:

…/hosts/file_a
…/hosts/file_b
…/hosts/host_vars/

right?

How do I prevent Ansible from trying to load contents of host_vars as inventory files?

Best regards,
Grzegorz Nosek

W dniu wtorek, 8 października 2013 17:56:26 UTC+2 użytkownik Michael DeHaan napisał:

In case somebody else wonders, Ansible does that out of the box:

if i.endswith(“~”) or i.endswith(“.orig”) or i.endswith(“.bak”):
continue
if i.endswith(“.ini”):

configuration file for an inventory script

continue
if i.endswith(“.retry”):

this file is generated on a failed playbook and should only be

used when run specifically

continue

Skip hidden files

if i.startswith(‘.’) and not i.startswith(‘./’):
continue

These are things inside of an inventory basedir

if i in (“host_vars”, “group_vars”, “vars_plugins”):
continue

Best regards,
Grzegorz Nosek

“How do I prevent Ansible from trying to load contents of host_vars as inventory files?”

Shouldn’t be doing that. If you can share steps to reproduce please file a github ticket and I’ll take a look.