Combine multiple inventory sources?

Hi all,

[Sorry for the barrage of mails, I am restructuring my Ansible layout and running into several things at once.]

I thought it was possible to combine inventory sources like this:

hosts/static1

I am confused why you have group definitions inside a file that seems to describe a host.

Should the “hosts/” directory just be named “inventory” ?

Anyway, yes, if you feed -i a path to a directory, it will load all inventory sources therein.

It is however true there are some unmerged things that will address what happens when the individual inventory files have information overlap. svg worked on this and it’s in queue after we smite some other various buglets.

​Joost,​

hosts/static1
---
[group1]
host1

hosts/static2
---
[group2]
host1

test.yml
---
- hosts: all
  connection: local
  gather_facts: no
  tasks:
  - debug: var=hostvars

It looks like group1 is somehow masking group2 during limiting:

$ ansible-playbook test.yml -i hosts -l group1

PLAY [all]
********************************************************************

TASK: [debug var=group_names]
*************************************************
ok: [host1] => {
    "group_names": [
        "group1",
        "group2"
    ]
}

​This is correct.

$ ansible-playbook test.yml -i hosts -l group2
ERROR: provided hosts list is empty

​I can reproduce this with standard ansible.
I get expected output with my integration branch that holds the different
patches Michael mentioned:
https://github.com/sergevanginderachter/ansible/tree/INTEGRATION

Is this a bug?

​Yes, and it will get solved :slight_smile:

Serge

I am confused why you have group definitions inside a file that seems to
describe a host.

Should the "hosts/" directory just be named "inventory" ?

Yes, it should be named "inventory".

​No, I believe it's planned for review in this release cycle, but they're
tackling higher priority tickets first.​

Yes, this exactly.

This is at the head of the feature list (we’ll it’s got some fixes in it for sure, but its’ well into the refactoring tickets), though we are currently working P2 tickets regarding some of the higher priority bugs in the system.