# List in lists

**URL:** <https://forum.ansible.com/t/list-in-lists/23906>\
**Category:** Ansible Project\
**Created:** [March 8, 2017, 8:57am UTC](https://forum.ansible.com/t/list-in-lists/23906 "2017-03-08T08:57:15Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![oravirt](https://avatars.discourse-cdn.com/v4/letter/o/3e96dc/32.png) [@oravirt](https://forum.ansible.com/u/oravirt)\
**Post date:** [March 8, 2017, 8:57am UTC](https://forum.ansible.com/t/list-in-lists/23906/1 "2017-03-08T08:57:15Z")

</div>

Hi,

Gist available at: [https://gist.github.com/oravirt/c13406766e820e99be9d1e5c30562075](https://gist.github.com/oravirt/c13406766e820e99be9d1e5c30562075)

I’ve got a structure like this:

`  
blergh:

- parent: first\_layer  
first\_layer\_list:
- { name: first\_layer\_list\_1st\_name }
- { name: first\_layer\_list\_2nd\_name }  
child:
- name: second\_layer  
second\_layer\_list:
- {name: second\_layer\_list\_1st\_name}
- {name: second\_layer\_list\_2nd\_name}

`

I want to access the elements in the second\_layer\_list, but not sure if that is possible.

I can access the ‘child.name’, with no problems (using with\_subelements), but I’m not sure how to get deeper into the structure.

The whole point of the structure is that you can have x number of ‘parent’ with y number of o names (first\_layer\_list). It is also possible to have x number of ‘child’ within the parent which in turn also can have x number of names (second\_layer\_list)

One option could be to move ‘child’ to its own list (like blergh) and ‘join’ child.name to blergh.parent key, but I’d rather keep it in the same structure if possible.

Any ideas?

regards  
/M
