title: Ansible loop till the condition matches.
body: <p>I want to make the series of API calls, after each call check for a particular parameter in the result, if it greater than particular value save it in register and continue further playbook execution.</p>
  
  <p>Basically I am making an API call to RHEV to check the storage domain. Then I want to check if storage domain have the sufficient space, if yes, store that storage domain id in register to create the disk on the storage domain. </p>
  
  <p>Below is the snippet how I do it for single API call to storagedomain. </p>
  
  <pre><code> - name: Get Free Storage Domain On RHEV
    uri:
      url: "{{ rhevurl }}/storagedomains/7649aea2-d87c-4066-acca-4399d5261ade"
      method: GET
      user: "{{ rhevusername }}"
      password: "{{ rhevpassword }}"
      return_content: yes
      headers:
        Version: 4
        Accept: "application/xml"
        Content-type: "application/xml"
    register: storagedomain
    tags: storagedomain
  
  
  - name: Retriving size.
    xml:
      xmlstring: "{{ storagedomain.content }}"
      xpath: /storage_domain/available
      content: text
    register: availablesize
    tags: storagedomain
  
  
  - name: storage_domain size
    debug:
      var: availablesize.matches[0].available
    tags: storagedomain
  </code></pre>
  
  <p>Now I want to do this process for multiple storage domain, and loop should break when it gets storagedomain with available space. </p>
  
  <p>Something like below.</p>
  
  <pre><code>- name: Get Free Storage Domain On RHEV
    uri:
      url: "{{ rhevurl }}/storagedomains/{{ item }}"
      method: GET
      user: "{{ rhevusername }}"
      password: "{{ rhevpassword }}"
      return_content: yes
      headers:
        Version: 4
        Accept: "application/xml"
        Content-type: "application/xml"
    loop:
      - 7649aea2-d87c-4066-acca-4399d5261ade
      - 40cceee7-a8d3-45af-a2d0-70c414be32cc
      - a81411b0-4ddb-4467-a4c6-ac9364905248
      - b288c547-231c-44b9-8329-98adcbdfc726 
      - 8cdef991-3edc-4c35-9228-feeef8f29004
      - 837a2e1b-6365-4309-a526-0cd05801fe43
      - 8981bf82-a1da-405e-a7f5-d84f2c94d71d
      - 7a9e3904-e37b-48fd-b850-0f026dc5cde9
  </code></pre>
  
  <p>In the loop how should I parse xml using xml module and then check for condition of available space greater the particular size</p>