# Ansible nested dictionary seems to do weird stuff with identical sub-groups

**URL:** <https://forum.ansible.com/t/ansible-nested-dictionary-seems-to-do-weird-stuff-with-identical-sub-groups/28764>\
**Category:** Ansible Project\
**Created:** [October 11, 2018, 9:06am UTC](https://forum.ansible.com/t/ansible-nested-dictionary-seems-to-do-weird-stuff-with-identical-sub-groups/28764 "2018-10-11T09:06:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![I\_Viridis](https://avatars.discourse-cdn.com/v4/letter/i/b38774/32.png) [@I\_Viridis](https://forum.ansible.com/u/I_Viridis)\
**Post date:** [October 11, 2018, 9:06am UTC](https://forum.ansible.com/t/ansible-nested-dictionary-seems-to-do-weird-stuff-with-identical-sub-groups/28764/1 "2018-10-11T09:06:45Z")

</div>

`

# inventory.yml

europe:  
children:  
germany:  
children:  
on-premise:  
hosts:  
127.0.0.1:  
datacenter:  
hosts:  
127.0.0.2:  
france:  
children:  
on-premise:  
hosts:  
127.0.0.3:  
datacenter:  
hosts:  
127.0.0.4:

`

Running the following command with different `--limit` options:

`  
ansible-playbook -i inventory.yml random-playbook.yml --limit 'some-limit

`

- `europe` I expect to run 127.0.0.1, 127.0.0.2, 127.0.0.3, 127.0.0.4
- `on-premise` I expect to run 127.0.0.1, 127.0.0.3
- `datacenter` I expect run 127.0.0.2, 127.0.0.4
- `germany` I expect to run 127.0.0.1, 127.0.0.2
- `france` I expect to run 127.0.0.3, 127.0.0.4

Now, my issue:

- Europe works as expected
- on-premise works as expected
- datacenter works as expected
- germany runs 127.0.0.1, 127.0.0.2, 127.0.0.3, 127.0.0.4
- france runs 127.0.0.1, 127.0.0.2, 127.0.0.3, 127.0.0.4

After playing with it for a while, it seemed like this behaviour is gone once you don’t have 2 on-premise or 2 datacenter children in germany and france.

It feels like while creating the host list it is just like ‘alright, france, on-premise and datacenter are children … get all the children/hosts of that group’ … after which he finds hosts in `datacenter` group that never belonged to France in the first place.

I was just wondering if I’m doing this wrong, or whether this is intended behaviour

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [October 11, 2018, 6:57pm UTC](https://forum.ansible.com/t/ansible-nested-dictionary-seems-to-do-weird-stuff-with-identical-sub-groups/28764/2 "2018-10-11T18:57:36Z")

</div>

Those are not 'sub-groups' they are the same group. you are giving  
them a parent/child relationship but all groups are 'global' so the  
same name refers to the same group.  
Only one 'on-premise' group exists, it is a chidl of france AND  
germany, any hosts you assign to it at any point are always part of  
that group.
