Loop over an array and assigning to url within uri module

133 views
Skip to first unread message

Mohammed Reehan

unread,
Mar 7, 2024, 6:41:32 PM3/7/24
to ansible...@googlegroups.com
Hi Team

i have an array from my previous playbook and saving it as a fact called as
"ansible_facts"{
   "response_cloud_id": [
   "34eedfc",
   "6733fdc"
  ]
},

I want to use this response_cloud_id for each object as a variable and pass into my URI module in the URL
https://cloudzone.net/api/{{ response_cloud_id }}/zone
how can I assign every element in the array to the URL loop through the array in the URL and make multiple calls till the array length is met?

Please help, 

thanks
Reehan


--
Mohammed Rehan

Todd Lewis

unread,
Mar 7, 2024, 7:36:13 PM3/7/24
to ansible...@googlegroups.com, uto...@gmail.com
- name: Run uri in a loop
  ansible.builtin.uri:
    url: https://cloudzone.net/api/{{ item }}/zone
  loop: '{{ response_cloud_id }}'
See https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_loops.html#standard-loops
--
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 ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAJOW%3Dx9%2B-LgbE0cE9yxhLg71S6ZH%3D_d3Wn8r2Mx7TxVYdsdc_g%40mail.gmail.com.

-- 
Todd
Reply all
Reply to author
Forward
0 new messages