# Waiting for servers after reboot

**URL:** <https://forum.ansible.com/t/waiting-for-servers-after-reboot/14371>\
**Category:** Ansible Project\
**Created:** [January 17, 2014, 8:25pm UTC](https://forum.ansible.com/t/waiting-for-servers-after-reboot/14371 "2014-01-17T20:25:47Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anand\_Buddhdev2](https://avatars.discourse-cdn.com/v4/letter/a/48db29/32.png) [@Anand\_Buddhdev2](https://forum.ansible.com/u/Anand_Buddhdev2)\
**Post date:** [January 17, 2014, 8:25pm UTC](https://forum.ansible.com/t/waiting-for-servers-after-reboot/14371/1 "2014-01-17T20:25:47Z")

</div>

Hi ansible users,

I have a playbook to reboot all my servers serially, using the “serial: 1” option in the playbook. I have the tasks:

- command: /sbin/reboot

- local\_action: wait\_for host={{inventory\_hostname}} port=22 state=stopped

- local\_action: wait\_for host={{inventory\_hostname}} port=22

However, some of my managed servers are not directly reachable from my laptop, so I usually connect to them via a bastion host. This means that the port 22 test will fail for them.

I thought about using the ping module instead, which should just do an SSH ping to a host. However, the ping module times out after a while when the underlying ssh connection times out, so I can’t make it wait long enough for the server to finish rebooting.

Does anyone have any ideas or suggestions on how to work around this?

Anand

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [January 17, 2014, 8:38pm UTC](https://forum.ansible.com/t/waiting-for-servers-after-reboot/14371/2 "2014-01-17T20:38:41Z")

</div>

“However, some of my managed servers are not directly reachable from my laptop, so I usually connect to them via a bastion host. This means that the port 22 test will fail for them.”

You could consider running Ansible from the bastion host, versus using an SSH jumphost which I infer you are using above.

The ping module doesn’t ICMP ping, BTW, it’s a basic Ansible connectivity test.

---

<div class="post-metadata">

**Author:** ![Anand\_Buddhdev2](https://avatars.discourse-cdn.com/v4/letter/a/48db29/32.png) [@Anand\_Buddhdev2](https://forum.ansible.com/u/Anand_Buddhdev2)\
**Post date:** [January 17, 2014, 8:59pm UTC](https://forum.ansible.com/t/waiting-for-servers-after-reboot/14371/3 "2014-01-17T20:59:01Z")

</div>

> You could consider running Ansible from the bastion host, versus using an SSH jumphost which I infer you are using above.

Yes, by bastion, I meant an SSH jump host.

> The ping module doesn’t ICMP ping, BTW, it’s a basic Ansible connectivity test.

Yes, I realise that the ansible ping module is not ICMP, but an SSH connection. The SSH jump host doesn’t have ansible installed, and I don’t have root access on it. I can of course install ansible in a virtualenv, but I was hoping for some cleverer way of detecting host down/up from within a playbook run from my laptop. I suppose my use-case is an outlier, so I’ll try to see what I can do on the jump host.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [January 17, 2014, 9:47pm UTC](https://forum.ansible.com/t/waiting-for-servers-after-reboot/14371/4 "2014-01-17T21:47:43Z")

</div>

Yeah, I’m open to the idea of a ping module action\_plugin that takes a ‘mode=icmp’ (default ssh).

You could also just do a “shell: ping” (making sure to ping just once) and register the return code.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [January 17, 2014, 9:47pm UTC](https://forum.ansible.com/t/waiting-for-servers-after-reboot/14371/5 "2014-01-17T21:47:52Z")

</div>

i.e. local\_action: ping …

---

<div class="post-metadata">

**Author:** ![Zack\_Perry](https://avatars.discourse-cdn.com/v4/letter/z/54ee81/32.png) [@Zack\_Perry](https://forum.ansible.com/u/Zack_Perry)\
**Post date:** [July 12, 2014, 6:41pm UTC](https://forum.ansible.com/t/waiting-for-servers-after-reboot/14371/6 "2014-07-12T18:41:58Z")

</div>

I am running into a similar situation and have been thinking about using the shell: ping approach too. But what I came up in the following didn’t seem to do the trick. Would appreciate a hint:

---

<div class="post-metadata">

**Author:** ![Zack\_Perry](https://avatars.discourse-cdn.com/v4/letter/z/54ee81/32.png) [@Zack\_Perry](https://forum.ansible.com/u/Zack_Perry)\
**Post date:** [July 12, 2014, 6:51pm UTC](https://forum.ansible.com/t/waiting-for-servers-after-reboot/14371/7 "2014-07-12T18:51:49Z")

</div>

Quick correction and follow-up:

I should have been more careful when cut-n-paste.

The task include file should be
