For example, if I want a task to pull ec2_instance_facts until any instance is in running state, and retry if none is running.
---
- hosts: localhost
gather_facts: no
connection: local
tasks:
- name: get ec2_instance_facts
ec2_instance_facts:
register: my_ec2
with_items: '{{ my_ec2.instances }}'
But I am getting error, because my_ec2 is not defined yet.
TASK [get ec2_instance_facts] **********************************************************************************************
fatal: [localhost]: FAILED! => {"failed": true, "msg": "'my_ec2' is undefined"}
Is it possible to loop over the result and retry the task in a single task? If I have to make a second task to loop over the result, I can't go back to retry the first task. How does Ansible handle retry of multiple tasks?
Thanks