Example, I have 3 tasks, which are registered ec21
, ec22
and ec23
.
ec22
runs when ec21
fails, and ec23
runs when ec22
fails.
Now, I have another task below it which is :
- name: Add new instance to host group
add_host:
hostname: "{{ item.private_ip }}"
groupname: launched
with_items: "{{ ec2x.instances }}"
where ec2x
is any of the previous tasks.
So, how do I set ec2x
here? cause, Any of my 3 tasks can run. So, it can be ec21
or ec22
or ec23
. So, how do I dynamically write that in the adding task after them?