# Loop Not Able to Parse After First iteration

**URL:** <https://forum.ansible.com/t/loop-not-able-to-parse-after-first-iteration/38091>\
**Category:** Ansible Project\
**Created:** [June 12, 2023, 6:52pm UTC](https://forum.ansible.com/t/loop-not-able-to-parse-after-first-iteration/38091 "2023-06-12T18:52:43Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![javed\_khan\_siddque](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/javed_khan_siddque/32/4964_2.png) [@javed\_khan\_siddque](https://forum.ansible.com/u/javed_khan_siddque)\
**Post date:** [June 12, 2023, 6:52pm UTC](https://forum.ansible.com/t/loop-not-able-to-parse-after-first-iteration/38091/1 "2023-06-12T18:52:43Z")

</div>

i required to create a list of paths but it is failing after first iteration

---

<div class="post-metadata">

**Author:** ![vbotka](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/vbotka/32/359_2.png) [@vbotka](https://forum.ansible.com/u/vbotka)\
**Post date:** [June 12, 2023, 10:11pm UTC](https://forum.ansible.com/t/loop-not-able-to-parse-after-first-iteration/38091/2 "2023-06-12T22:11:38Z")

</div>

Given the variables for testing

&nbsp;&nbsp;center: "SSDC"  
&nbsp;&nbsp;cluster: "server"  
&nbsp;&nbsp;division: "div"  
&nbsp;&nbsp;region: "reg"  
&nbsp;&nbsp;env: "env"  
&nbsp;&nbsp;app\_id: "1234"  
&nbsp;&nbsp;list\_of\_sequence: "{{ range(1, 10) }}"

Declare \*path\*, \*prefix\*, and \*app\*. You have to convert \*app\_id\*  
from string to integer because you quotes the number

&nbsp;&nbsp;path: "/ifs/{{ center }}/{{ cluster }}"  
&nbsp;&nbsp;prefix: "{{ division }}{{ region }}{{ env }}"  
&nbsp;&nbsp;app: "{{ '%05d' % (app\_id|int) }}"

Use Jinja template to create the list

&nbsp;&nbsp;my\_list: |  
&nbsp;&nbsp;&nbsp;&nbsp;{% filter from\_yaml %}  
&nbsp;&nbsp;&nbsp;&nbsp;{% for i in list\_of\_sequence %}  
&nbsp;&nbsp;&nbsp;&nbsp;- {{ path }}/{{ prefix|upper }}{{ app }}{{ '%02d' % (i) }}  
&nbsp;&nbsp;&nbsp;&nbsp;{% endfor %}  
&nbsp;&nbsp;&nbsp;&nbsp;{% endfilter %}

gives

&nbsp;&nbsp;my\_list:  
&nbsp;&nbsp;- /ifs/SSDC/server/DIVREGENV0123401  
&nbsp;&nbsp;- /ifs/SSDC/server/DIVREGENV0123402  
&nbsp;&nbsp;- /ifs/SSDC/server/DIVREGENV0123403  
&nbsp;&nbsp;- /ifs/SSDC/server/DIVREGENV0123404  
&nbsp;&nbsp;- /ifs/SSDC/server/DIVREGENV0123405  
&nbsp;&nbsp;- /ifs/SSDC/server/DIVREGENV0123406  
&nbsp;&nbsp;- /ifs/SSDC/server/DIVREGENV0123407  
&nbsp;&nbsp;- /ifs/SSDC/server/DIVREGENV0123408  
&nbsp;&nbsp;- /ifs/SSDC/server/DIVREGENV0123409
