# wait\_for through bastion stalls

**URL:** <https://forum.ansible.com/t/wait-for-through-bastion-stalls/18521>\
**Category:** Ansible Project\
**Created:** [June 16, 2015, 5:16pm UTC](https://forum.ansible.com/t/wait-for-through-bastion-stalls/18521 "2015-06-16T17:16:03Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![David\_Pires](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@David\_Pires](https://forum.ansible.com/u/David_Pires)\
**Post date:** [June 16, 2015, 5:16pm UTC](https://forum.ansible.com/t/wait-for-through-bastion-stalls/18521/1 "2015-06-16T17:16:03Z")

</div>

I am having a weird issue when launching ec2 instances. I have a playbook where I launch an instance into a private VPC, using item.private\_ip etc.

My ssh config is setup to proxy requests to any host in this subnet. I can ssh successfully into any host, using my bastion and ssh config, so I know this is working correctly.

When I am launching an ec2 instance, my wait\_for local action always times out, it can’t connect “msg: Timeout when waiting for ”, however, after the playbook fails I can ssh into this host, and adding this host into my inventory file also works.

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [June 17, 2015, 12:33am UTC](https://forum.ansible.com/t/wait-for-through-bastion-stalls/18521/2 "2015-06-17T00:33:56Z")

</div>

That makes sense since wait\_for does not have direct access (it just  
uses a socket call), you might need to delegate the wait for to the  
bastion machine.

---

<div class="post-metadata">

**Author:** ![David\_Pires](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@David\_Pires](https://forum.ansible.com/u/David_Pires)\
**Post date:** [June 17, 2015, 2:47am UTC](https://forum.ansible.com/t/wait-for-through-bastion-stalls/18521/3 "2015-06-17T02:47:07Z")

</div>

> - name: Wait for SSH
> 
> delegate\_to:
> 
> wait\_for:
> 
> host={{ item.private\_ip }}
> 
> port=22
> 
> state=started
> 
> with\_items: ec2.instances

I have tried delegating the wait\_for, and with debug on, I can see that the task is being run on the bastion host. I am still having the same issue.

While it is stuck on the wait\_for task, i can ssh from the bastion to the new instance, so I know it’s not a timing issue, and as soon as the task fails, I can ssh directly from my ansible host.

I can get around the issue by removing the wait\_for and use a pause task, but i’d like to know what i’m doing wrong.

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [June 17, 2015, 3:18am UTC](https://forum.ansible.com/t/wait-for-through-bastion-stalls/18521/4 "2015-06-17T03:18:23Z")

</div>

You might want to add a small delay to wait\_for (10s is normally good).

---

<div class="post-metadata">

**Author:** ![David\_Pires](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@David\_Pires](https://forum.ansible.com/u/David_Pires)\
**Post date:** [June 17, 2015, 4:06pm UTC](https://forum.ansible.com/t/wait-for-through-bastion-stalls/18521/5 "2015-06-17T16:06:04Z")

</div>

I’ve added a 10s delay, no luck.

I must have something else configured incorrectly, I’ll just replace my wait\_for with a pause for now, that works.

---

<div class="post-metadata">

**Author:** ![Khoa\_Nguyen](https://avatars.discourse-cdn.com/v4/letter/k/54ee81/32.png) [@Khoa\_Nguyen](https://forum.ansible.com/u/Khoa_Nguyen)\
**Post date:** [September 28, 2015, 10:27am UTC](https://forum.ansible.com/t/wait-for-through-bastion-stalls/18521/6 "2015-09-28T10:27:17Z")

</div>

Hi David,

You can use delegate\_to for wait\_for.

Remove: connection: local  
Add: remote\_user: of delegate instance. For example: ubuntu

- hosts: localhost

#connection: local

gather\_facts: False

Regards,  
Khoa Nguyen
