# How to iterate over below hash

**URL:** <https://forum.ansible.com/t/how-to-iterate-over-below-hash/23710>\
**Category:** Ansible Project\
**Created:** [February 11, 2017, 3:00pm UTC](https://forum.ansible.com/t/how-to-iterate-over-below-hash/23710 "2017-02-11T15:00:13Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![D11](https://avatars.discourse-cdn.com/v4/letter/d/47e85d/32.png) [@D11](https://forum.ansible.com/u/D11)\
**Post date:** [February 11, 2017, 3:00pm UTC](https://forum.ansible.com/t/how-to-iterate-over-below-hash/23710/1 "2017-02-11T15:00:13Z")

</div>

Hello,

I am new to ansible, i have requirement.

vars:  
locations:  
&nbsp;&nbsp;- parentlocation: A  
&nbsp;&nbsp;&nbsp;&nbsp;childlocation:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- a1  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- a2  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- a3  
- parentlocation: B  
&nbsp;&nbsp;&nbsp;childlocation:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- b1  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- b2  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- b3

Now i want run task so

- name: create parent location  
command:  
&nbsp;&nbsp;some command '{{ parentlocation }}' create

- name: create child loc aslo pass parent of it  
&nbsp;&nbsp;command:  
&nbsp;&nbsp;&nbsp;&nbsp;some command '{{ parentlocation }}' --child '{{ childlocation[0,1,3..]

How do i iterate ??

Basically i wilk create parent locatuon and when i create child location i need to pass its parent as well so it creates hierarchies

Thanks,  
Dj
