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/ 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 }}" ~ 

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/19beb920-30b7-41cd-8f7b-771cc586eec6n%40googlegroups.com.

Reply via email to