Hi all,

I am pretty new to Ansible. I am using ec2.py to connect to my EC2 
instances and run my ansible scripts on them. Previously, it was working 
fine when I was using "all" regions. But now when I change the region to a 
specific one region (any of the available ones), in ec2.ini, it gives me 
below error for the first time and after second time onward, it works well.

UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via 
ssh.", "unreachable": true}


What I do is use ec2 module to create a instance and then wait_for port 22 
on each host to be up. It wait successfully and moves forward but in the 
immediate next step when I try to connect to the instance, it gives above 
error first time. Here is my wait_for task: (ec2_server is the variable 
registered from ec2 module)

name: wait for ssh server to be running
    wait_for: host={{ item.public_dns_name }} port=22
    with_items: "{{ec2_server.instances | default([])}}"
    when: item.state == 'running'


I ping in between to the instance using private ip and the ping succeeds. I 
suspect it is some timing issue or DNS name resolution issue with AWS. Has 
anyone faced such problem before?

Any help would be appreciated. Thanks !

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/f5fc7534-2737-483f-b7b3-d2be8ef33ec0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to