0

I have a play that search for available storage in vm datastore to find disk space.

- name: Select the datastore which has minimum of 500GB
  include_role: find_disk_space_datastore
  with_item:
     -datastore_001
     -datastore_002
     -datastore_003

Role: roles/find_disk_space_datastore/tasks/main.yml

 - name: search for domain {{ item }}
   blah ...blah save the free space on {{ disk_space }} variable


 - name: find the datastore
   setfact:
      datastore_name:
   when: {{ disk_space }} >> 500

Assume I have found free space in second item which is datastore_002 instead of going to datastore_003 in the loop how can I exit from there ?????

note - I need to break the loop in between.

thank you inadvanced

Smily
  • 2,308
  • 2
  • 17
  • 41
Ravi
  • 23
  • 4
  • Looks like it may not be possible: https://stackoverflow.com/questions/53171738/how-can-i-break-the-with-items-loop-based-on-a-condition – pjd Oct 04 '19 at 05:36
  • See [How to go rescue module when any package fails in Ansible Playbook](https://serverfault.com/questions/986545/how-to-go-rescue-module-when-any-package-fails-in-ansible-playbook/). – Vladimir Botka Oct 04 '19 at 07:00

0 Answers0