The yml I've written works properly if I've created only one ec2instance but in case I've to provision more than 1 ec2 instances then this yml code fails.
I want to wait for the ssh to come up for 2 different ec2 instances
- name: 7. Wait for SSH to come up
local_action: wait_for
host={{ item.public_ip }}
port=22
state=started
with_items: "{{ ec2.instances }}"