# quick question on developing dynamic inventory files

**URL:** <https://forum.ansible.com/t/quick-question-on-developing-dynamic-inventory-files/15079>\
**Category:** Ansible Project\
**Created:** [April 23, 2014, 9:24pm UTC](https://forum.ansible.com/t/quick-question-on-developing-dynamic-inventory-files/15079 "2014-04-23T21:24:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Seth\_Edwards](https://avatars.discourse-cdn.com/v4/letter/s/a88e57/32.png) [@Seth\_Edwards](https://forum.ansible.com/u/Seth_Edwards)\
**Post date:** [April 23, 2014, 9:24pm UTC](https://forum.ansible.com/t/quick-question-on-developing-dynamic-inventory-files/15079/1 "2014-04-23T21:24:46Z")

</div>

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

```auto
{
    "all" : {
        "vars" : {
            "a" : true, 

```

```auto
        }
    },

```

```auto
.........

```

---

<div class="post-metadata">

**Author:** ![sivel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sivel/32/1198_2.png) [@sivel](https://forum.ansible.com/u/sivel)\
**Post date:** [April 23, 2014, 9:27pm UTC](https://forum.ansible.com/t/quick-question-on-developing-dynamic-inventory-files/15079/2 "2014-04-23T21:27:32Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Serge\_van\_Ginderacht](https://avatars.discourse-cdn.com/v4/letter/s/b782af/32.png) [@Serge\_van\_Ginderacht](https://forum.ansible.com/u/Serge_van_Ginderacht)\
**Post date:** [April 24, 2014, 7:42am UTC](https://forum.ansible.com/t/quick-question-on-developing-dynamic-inventory-files/15079/3 "2014-04-24T07:42:28Z")

</div>

> 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.
