# Help with Looping

**URL:** <https://forum.ansible.com/t/help-with-looping/38383>\
**Category:** AWX Project\
**Created:** [August 28, 2023, 9:08pm UTC](https://forum.ansible.com/t/help-with-looping/38383 "2023-08-28T21:08:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bariou\_Alarou](https://avatars.discourse-cdn.com/v4/letter/b/71e660/32.png) [@Bariou\_Alarou](https://forum.ansible.com/u/Bariou_Alarou)\
**Post date:** [August 28, 2023, 9:08pm UTC](https://forum.ansible.com/t/help-with-looping/38383/1 "2023-08-28T21:08:19Z")

</div>

Good Evening team,

I need help with ansible looping during Dynatrace API call for creating multiple management zones.

Here is code below

- name: “create management zone”  
uri:  
url: “{{ dt\_config\_api\_endpoint }}managementZones/{{ dt\_mz\_64id }}?Api-Token={{ dt\_api\_token }}”  
method: PUT  
body:  
id: “{{ dt\_mz\_64id }}”  
name: “{{ item.name }}”  
rules:
- type: CUSTOM\_DEVICE  
enabled: true  
propagationTypes:   
conditions:
- key:  
attribute: CUSTOM\_DEVICE\_TAGS  
comparisonInfo:  
type: “TAG”  
operator: EQUALS  
value:  
key: “ApplicationID”  
context: “CONTEXTLESS”  
value: “{{ item.dt\_tag\_value }}”  
negate: false  
body\_format: json  
status\_code: 201  
return\_content: yes  
loop: “{{ dt\_mz\_name }}”  
register: new\_mz

Variable file where list of management zones along with tags number is  
dt\_mz\_name:

- name: “PRODUCTION STANDBY”  
dt\_tag\_value: 111111111 }
- name: “BENTLEYProduction”  
dt\_tag\_value: 222222222 }
- name: “PEVIProduction”  
dt\_tag\_value: 33333333}

Now when I ran playbook. It only create first management zones with tag and job then failed.

Any help

---

<div class="post-metadata">

**Author:** ![disi](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/disi/32/1138_2.png) [@disi](https://forum.ansible.com/u/disi)\
**Post date:** [August 30, 2023, 10:05pm UTC](https://forum.ansible.com/t/help-with-looping/38383/2 "2023-08-30T22:05:19Z")

</div>

Are the winged brackets in the list of items part of the value?  
I can only think it may interfere with the processing of the runbook.

Maybe do something like dt\_tag\_value: “222222222 }” if they need to be part of it.

---

<div class="post-metadata">

**Author:** ![AWX\_Project](https://avatars.discourse-cdn.com/v4/letter/a/eada6e/32.png) [@AWX\_Project](https://forum.ansible.com/u/AWX_Project)\
**Post date:** [September 6, 2023, 6:40pm UTC](https://forum.ansible.com/t/help-with-looping/38383/3 "2023-09-06T18:40:01Z")

</div>

were you able to resolve this?
