Combine multiple inventory sources?

888 views
Skip to first unread message

Joost Cassee

unread,
May 28, 2014, 9:56:43 AM5/28/14
to ansible...@googlegroups.com
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
---
[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"
    ]
}

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

Is this a bug?

Regards,
Joost

Michael DeHaan

unread,
May 28, 2014, 11:48:30 AM5/28/14
to ansible...@googlegroups.com
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.




--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/06798cc1-c530-4c90-9f25-e726ffe20cc2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Serge van Ginderachter

unread,
May 28, 2014, 12:01:20 PM5/28/14
to ansible...@googlegroups.com

​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:


Is this a bug?

​Yes, and it will get solved :)



Serge

Joost Cassee

unread,
May 28, 2014, 3:09:26 PM5/28/14
to ansible...@googlegroups.com
2014-05-28 17:48 GMT+02:00 Michael DeHaan <mic...@ansible.com>:
> 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".

2014-05-28 18:00 GMT+02:00 Serge van Ginderachter <se...@vanginderachter.be>:
>> $ 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 :)

Great, thank for reproducing! Do you have an idea of when those
changes will land in devel?

Regards,
Joost

--
Joost Cassee
http://joost.cassee.net

Serge van Ginderachter

unread,
May 28, 2014, 4:55:17 PM5/28/14
to ansible...@googlegroups.com

On 28 May 2014 21:08, Joost Cassee <jo...@cassee.net> wrote:
Great, thank for reproducing! Do you have an idea of when those
changes will land in devel?

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

Michael DeHaan

unread,
May 29, 2014, 2:02:18 PM5/29/14
to ansible...@googlegroups.com
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.


--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages