Hi everyone:

I'm new to Ansible and am hoping there's an easy answer for this. I have a 
playbook which needs to iterate through a list of IP addresses POSTing a 
request to each via the uri module, but *only until* the first successful 
response is received. Once a 200 is returned I don't want it to continue. 
I've done the following but it hits all three endpoints even if the second 
one returns 200:

---
- hosts: 192.168.1.2
  vars:
    my_addrs:
      - "192.168.1.100"
      - "localhost"
      - "192.168.1.2"
  become: yes
  become_method: sudo
  tasks:
    - name: Query addresses until success
      with_items: my_addrs
      uri:
        register: uri_resp
        until: uri_resp.status == 200
        retries: 5
        url: "http://{{ item }}/_showSomething"
        method: POST
        body: "{\"foo\":\"bar\"}"
        body_format: json
        HEADER_Content-Type: "application/json"

...here I'm trying to iterate using "with_items", and trying to break using 
"until", but I haven't found an example of using these two together (let 
alone with the uri module), so I'm wondering what the right way of doing 
this is.

Thanks in advance for any insight!

-p

-- 
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 post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/a1b02118-687f-4b0b-9980-1d7d0093b2b5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to