# Retrieve only depth=1 children for a group in inventory

**URL:** <https://forum.ansible.com/t/retrieve-only-depth-1-children-for-a-group-in-inventory/20497>\
**Category:** Ansible Project\
**Created:** [February 9, 2016, 4:40pm UTC](https://forum.ansible.com/t/retrieve-only-depth-1-children-for-a-group-in-inventory/20497 "2016-02-09T16:40:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Christophe\_Boivin](https://avatars.discourse-cdn.com/v4/letter/c/d6d6ee/32.png) [@Christophe\_Boivin](https://forum.ansible.com/u/Christophe_Boivin)\
**Post date:** [February 9, 2016, 4:40pm UTC](https://forum.ansible.com/t/retrieve-only-depth-1-children-for-a-group-in-inventory/20497/1 "2016-02-09T16:40:32Z")

</div>

Hello,

I would like to get a list of only children of depth 1 for a certain group

If my inventory is :

> [group\_a:children]  
> group\_b  
> group\_c
> 
> [group\_b]  
> host1  
> host2
> 
> [group\_c]  
> host3

When I try to loop on items of group\_a:children i will get [host1, host2, host3]

Is there any way to get [group\_b, group\_c] ?

Thanks in advance

Christophe

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [February 9, 2016, 5:58pm UTC](https://forum.ansible.com/t/retrieve-only-depth-1-children-for-a-group-in-inventory/20497/2 "2016-02-09T17:58:57Z")

</div>

no, inventory is flattened on read, so once in ansible there are no child groups/hosts, just hosts and it’s groups.

---

<div class="post-metadata">

**Author:** ![Christophe\_Boivin](https://avatars.discourse-cdn.com/v4/letter/c/d6d6ee/32.png) [@Christophe\_Boivin](https://forum.ansible.com/u/Christophe_Boivin)\
**Post date:** [February 9, 2016, 7:52pm UTC](https://forum.ansible.com/t/retrieve-only-depth-1-children-for-a-group-in-inventory/20497/3 "2016-02-09T19:52:15Z")

</div>

Don’t you think it could be a nice add to keep somewhere accessible the “model” that is described in the inventory ?
