quick question on developing dynamic inventory files

48 views
Skip to first unread message

Seth Edwards

unread,
Apr 23, 2014, 5:24:46 PM4/23/14
to ansible...@googlegroups.com
I am creating my own dynamic inventory script. I have some variables that need to exist for every group throughout any playbook for this inventory. If I just emit and "all" group with a vars dictionary, would that be enough to get this working? Thanks

{
    "all"   : {
        "vars"    : {
            "a"   : true, 
        }
    },
.........

Matt Martz

unread,
Apr 23, 2014, 5:27:32 PM4/23/14
to ansible...@googlegroups.com, Seth Edwards
I think the problem you will then run into, is that you will have to explicitly add all hosts to the 'all' group.

Using an inventory script is more explicit than an inventory file.  If you define 'all' I believe it treats your declaration of that group as the definitive truth, and if you leave out the servers, the 'all' group will then be empty.

-- 
Matt Martz
ma...@sivel.net
--
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/1a8a312d-018f-4206-992e-d03c5fff5d58%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Serge van Ginderachter

unread,
Apr 24, 2014, 3:42:28 AM4/24/14
to ansible...@googlegroups.com, Seth Edwards
On 23 April 2014 23:27, Matt Martz <ma...@sivel.net> wrote:
I think the problem you will then run into, is that you will have to explicitly add all hosts to the 'all' group.

​No, the script parsing will d​o that. Right now, every group is added as child of 'all' (instead of just top level groups)

Using an inventory script is more explicit than an inventory file.  If you define 'all' I believe it treats your declaration of that group as the definitive truth, and if you leave out the servers, the 'all' group will then be empty.

So the script will make sure that groups are children of all, so in the end, all hosts will be part of all (be it directly or indirectly). 


So to Seth's original question, yes, that will be working.

Reply all
Reply to author
Forward
0 new messages