# Mixing dynamic & static inventory : sharing groups

**URL:** <https://forum.ansible.com/t/mixing-dynamic-static-inventory-sharing-groups/14551>\
**Category:** Ansible Project\
**Created:** [February 12, 2014, 12:58pm UTC](https://forum.ansible.com/t/mixing-dynamic-static-inventory-sharing-groups/14551 "2014-02-12T12:58:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Michel\_Blanc](https://avatars.discourse-cdn.com/v4/letter/m/ba8739/32.png) [@Michel\_Blanc](https://forum.ansible.com/u/Michel_Blanc)\
**Post date:** [February 12, 2014, 12:58pm UTC](https://forum.ansible.com/t/mixing-dynamic-static-inventory-sharing-groups/14551/1 "2014-02-12T12:58:24Z")

</div>

Hi,

I'm trying to mix dynamic & static inventory, but I fall short having  
these inventories cooperating with each other.

My playbook is supposed to :  
- handle droplet creation on Digital Ocean  
- provision each droplet

Because of this, I do not know target host IPs in advance, and I don't  
want to fill 'ansible\_ssh\_host' manualy in my static inventory.

So my idea was to use the groups returned in by digital\_ocean.py  
inventory script, which creates groups based on DigitalOcean hostnames  
(among others) :

On the dynamic side, I'm using digital\_ocean.py inventory script :

&nbsp;&nbsp;$ inventory/digital\_ocean.py --pretty  
&nbsp;&nbsp;{  
&nbsp;&nbsp;&nbsp;&nbsp;...  
&nbsp;&nbsp;&nbsp;&nbsp;"web1.example.org": [  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"12.34.56.78"  
&nbsp;&nbsp;&nbsp;&nbsp;]  
&nbsp;&nbsp;}

So all seems well, I though could use this group in the static part :

&nbsp;&nbsp;$ cat inventory/hosts  
&nbsp;&nbsp;localhost gather\_facts=no ansible\_python\_interpreter=python2

&nbsp;&nbsp;[backends:children]  
&nbsp;&nbsp;web1.example.org

Now when I run `ansible all -i inventory/ --list-hosts` I get :

ERROR: child group is not defined: (web1.example.org)

It seems that the group created by digital\_ocean.py is not available in  
the static inventory part.

Is this intended, or am I missing something ?

Thanks for reading.

M

---

<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:** [February 12, 2014, 1:07pm UTC](https://forum.ansible.com/t/mixing-dynamic-static-inventory-sharing-groups/14551/2 "2014-02-12T13:07:38Z")

</div>

​files and scripts within an inventory are parsed separately from each  
other, and only merged afterwards.  
So at the time of the parsing of your hosts file, the parser doesn't know  
yet ​about that group.

Just add an empty group definition:

[web1.example.org]

​  
[backends:children]  
&nbsp;&nbsp;web1.example.org

​should do the trick

&nbsp;&nbsp;Serge​

---

<div class="post-metadata">

**Author:** ![Michel\_Blanc](https://avatars.discourse-cdn.com/v4/letter/m/ba8739/32.png) [@Michel\_Blanc](https://forum.ansible.com/u/Michel_Blanc)\
**Post date:** [February 12, 2014, 1:12pm UTC](https://forum.ansible.com/t/mixing-dynamic-static-inventory-sharing-groups/14551/3 "2014-02-12T13:12:59Z")

</div>

Awesome, that was it. Thanks a lot Serge !

M
