I would like to loop over a group of hosts (they are in inventory) with uri module, only until the status code is 200, and save this hostname to a variable.
What's written below is completely wrong, It's just to express my need.
(Note : I have 4 hosts in all_uri_group, I know the 2nd and 3rd ones have the status code 200, I want to stop the loop in 2nd host, and register the valid_host with the value of second hostname.
- name: Looking for valid host
hosts: all_uri_group
uri:
url: https://{{ fa_url }}/api/{{ api_version }}/volume
method: POST
validate_certs: no
return_content: yes
status_code: 200
register: reply
until: status_code == 200
retries: 0
delay: 0
But I have no idea how to correctly write it in Ansible.