# What's the correct way to reboot a server?

**URL:** <https://forum.ansible.com/t/whats-the-correct-way-to-reboot-a-server/14232>\
**Category:** Ansible Project\
**Created:** [December 29, 2013, 3:49pm UTC](https://forum.ansible.com/t/whats-the-correct-way-to-reboot-a-server/14232 "2013-12-29T15:49:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Geoff\_Oakham](https://avatars.discourse-cdn.com/v4/letter/g/5f8ce5/32.png) [@Geoff\_Oakham](https://forum.ansible.com/u/Geoff_Oakham)\
**Post date:** [December 29, 2013, 3:49pm UTC](https://forum.ansible.com/t/whats-the-correct-way-to-reboot-a-server/14232/1 "2013-12-29T15:49:45Z")

</div>

Hi everyone,

I’m new to Ansible and I’ve been exploring it with Vagrant to perform some automated deployment tests for a project. I’m enjoying it so far! As part of setting up the deployment environment, I need to adjust some kernel parameters which take effect at boot time. It’s easy to do: edit a file and reboot. I’m not sure how to do this using Ansible so that Ansible waits for the reboot to complete.

My first thought was use a pre\_task to set the kernel parameters and notify a ‘reboot’ handler like this [http://pastebin.com/A5BwUkY9](http://pastebin.com/A5BwUkY9) . But then other tasks would attempt to run in the middle of the reboot. I tried to resolve this using the “wait\_for: port=22”, but no dice… perhaps because the ssh daemon doesn’t get killed before Ansible checks.

Am I on the right track? What am I missing?

Thanks,

Geoff

---

<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:** [December 30, 2013, 4:37pm UTC](https://forum.ansible.com/t/whats-the-correct-way-to-reboot-a-server/14232/2 "2013-12-30T16:37:53Z")

</div>

wait\_for has a delay parameter so you can wait a given number of seconds before checking for port uptime.

This is generally what I’d suggest.

---

<div class="post-metadata">

**Author:** ![Mathias\_Bogaert](https://avatars.discourse-cdn.com/v4/letter/m/df788c/32.png) [@Mathias\_Bogaert](https://forum.ansible.com/u/Mathias_Bogaert)\
**Post date:** [December 30, 2013, 7:21pm UTC](https://forum.ansible.com/t/whats-the-correct-way-to-reboot-a-server/14232/3 "2013-12-30T19:21:31Z")

</div>

You can find an example here:

[https://github.com/analytically/hadoop-ansible/blob/master/roles/2\_aggregated\_links/tasks/main.yml](https://github.com/analytically/hadoop-ansible/blob/master/roles/2_aggregated_links/tasks/main.yml)

Cheers,

Mathias
