# Upgrades and reboots - question

**URL:** <https://forum.ansible.com/t/upgrades-and-reboots-question/16731>\
**Category:** Ansible Project\
**Created:** [November 10, 2014, 2:33am UTC](https://forum.ansible.com/t/upgrades-and-reboots-question/16731 "2014-11-10T02:33:55Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Patrick\_Galbraith](https://avatars.discourse-cdn.com/v4/letter/p/48db29/32.png) [@Patrick\_Galbraith](https://forum.ansible.com/u/Patrick_Galbraith)\
**Post date:** [November 10, 2014, 2:33am UTC](https://forum.ansible.com/t/upgrades-and-reboots-question/16731/1 "2014-11-10T02:33:55Z")

</div>

Hi all!

We’ve been working on a playbook that does a dist upgrade and then performs a reboot. This has been problematic and results in a failure return status that sometimes means it worked and sometimes not. What is the trick to reboots – being able to smoothly reconnect after a reboot signal?

---

<div class="post-metadata">

**Author:** ![j.r.hawkesworth](https://avatars.discourse-cdn.com/v4/letter/j/a3d4f5/32.png) [@j.r.hawkesworth](https://forum.ansible.com/u/j.r.hawkesworth)\
**Post date:** [November 10, 2014, 10:14am UTC](https://forum.ansible.com/t/upgrades-and-reboots-question/16731/2 "2014-11-10T10:14:49Z")

</div>

Just a guess but you might want to have a few seconds of delay set in your wait\_for so that there is time for network services and sshd to come back up before ansible goes looking for it.

---

<div class="post-metadata">

**Author:** ![Azul](https://avatars.discourse-cdn.com/v4/letter/a/91b2a8/32.png) [@Azul](https://forum.ansible.com/u/Azul)\
**Post date:** [November 11, 2014, 11:30am UTC](https://forum.ansible.com/t/upgrades-and-reboots-question/16731/3 "2014-11-11T11:30:17Z")

</div>

This works on my machine,

- name: wait for server to come back  
local\_action: shell while true; do echo “Waiting …” ; ssh -o ConnectTimeout=5 -o BatchMode=yes {{ inventory\_hostname }} pwd ; [$? -eq 0] && break || sleep 5; done  
sudo: false

---

<div class="post-metadata">

**Author:** ![John\_Batty](https://avatars.discourse-cdn.com/v4/letter/j/ecc23a/32.png) [@John\_Batty](https://forum.ansible.com/u/John_Batty)\
**Post date:** [November 14, 2014, 2:15pm UTC](https://forum.ansible.com/t/upgrades-and-reboots-question/16731/4 "2014-11-14T14:15:50Z")

</div>

Your server may still be in the process of shutting down when your “wait\_for” is executed. So the wait\_for could make a connection and think the server is back up when it is actually on its way down…

Try setting the delay parameter in the wait\_for (e.g to 15) to ensure that the server is down/rebooting before waif\_for starts checking.

John
