# how to use mutiple with\_items together in ansible

**URL:** <https://forum.ansible.com/t/how-to-use-mutiple-with-items-together-in-ansible/34872>\
**Category:** Ansible Project\
**Created:** [March 27, 2021, 6:26pm UTC](https://forum.ansible.com/t/how-to-use-mutiple-with-items-together-in-ansible/34872 "2021-03-27T18:26:52Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sanoj\_Thampi](https://avatars.discourse-cdn.com/v4/letter/s/65b543/32.png) [@Sanoj\_Thampi](https://forum.ansible.com/u/Sanoj_Thampi)\
**Post date:** [March 27, 2021, 6:26pm UTC](https://forum.ansible.com/t/how-to-use-mutiple-with-items-together-in-ansible/34872/1 "2021-03-27T18:26:52Z")

</div>

Here I have attached the input format of Json which consists of two arrays, objects and targets, I try to use the Ansible with\_item module to loop objects into the Uri module.

this concept is working with a single array, but facing issue when i try to call both array items to the uri. is there any way to use both array of items together

**Json input**

{ “objects”: [{ “item”: { “action”: “deny”, “srcaddr”: “IP\_100.1.2.3”, “src\_ipv4”: “ipmask”, “src\_ipv4addr”: “100.1.2.3/32”, “dstaddr”: “IP\_100.4.5.6”, “dst\_ipv4addr”: “100.4.5.6/32”, “dst\_ipv4”: “ipmask”, “port”: “65511”, “protocol”: “tcp” } }, { “item”: { “action”: “deny”, “srcaddr”: “IP\_200.1.2.3”, “src\_ipv4”: “ipmask”, “src\_ipv4addr”: “200.1.2.3/32”, “dstaddr”: “IP\_100.4.5.6”, “dst\_ipv4addr”: “100.4.5.6/32”, “dst\_ipv4”: “ipmask”, “port”: “65511”, “protocol”: “tcp” } }], “targets”: [{ “item”: { “domain”: “dom-cn-1”, “fingerprint”: “9125544D272B5AD28F3E9AB7BC8AA3F276E45064”, “mgmt\_password”: “admin123”, “mgmt\_server”: “192.168.10.20”, “target\_fw”: “dev-cn-c1” } }, { “item”: { “domain”: “dom-cn-2”, “fingerprint”: “9125544D272B5AD28F3E9AB7BC8AA3F276E45064”, “mgmt\_password”: “admin123”, “mgmt\_server”: “192.168.10.20”, “target\_fw”: “dev-cn-c3” } }] }

**task based on uri module**

- name: upating the task status uri: url: [http://192.168.30.20/api/v2/job\_templates/7/launch/](http://192.168.30.20/api/v2/job_templates/7/launch/) method: POST body: ‘{ “extra\_vars”: { “action”: “{{ item.item.action }}”, “srcaddr”: “{{ item.item.srcaddr }}”, “src\_ipv4”: “{{ item.item.src\_ipv4 }}”, “mgmt\_password”: “{{ item.item.mgmt\_password }}”, “mgmt\_server”: “{{ item.item.mgmt\_server }}”, “targets”: [“{{ item.item.target\_fw }}”]} }’ status\_code: 201 body\_format: json force\_basic\_auth: yes validate\_certs: no user: “admin” password: “admin123” headers: Accept: “application/json” Content-Type: “application/json” with\_items: “{{ tmpdata.objects }}” ~
