# Reboot servers strategy.

**URL:** <https://forum.ansible.com/t/reboot-servers-strategy/33276>\
**Category:** Ansible Project\
**Created:** [June 29, 2020, 7:26pm UTC](https://forum.ansible.com/t/reboot-servers-strategy/33276 "2020-06-29T19:26:03Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rafael\_Tomelin](https://avatars.discourse-cdn.com/v4/letter/r/da6949/32.png) [@Rafael\_Tomelin](https://forum.ansible.com/u/Rafael_Tomelin)\
**Post date:** [June 29, 2020, 7:26pm UTC](https://forum.ansible.com/t/reboot-servers-strategy/33276/1 "2020-06-29T19:26:03Z")

</div>

Hi Guys,  
I have periodic updates on all RedHat servers at the same time, I need to create a strategy to restart my clusters because I can’t stop my application and services.

How to create the reboot strategy server-per-server in clusters?

---

<div class="post-metadata">

**Author:** ![jcpetro](https://avatars.discourse-cdn.com/v4/letter/j/53a042/32.png) [@jcpetro](https://forum.ansible.com/u/jcpetro)\
**Post date:** [June 30, 2020, 7:16pm UTC](https://forum.ansible.com/t/reboot-servers-strategy/33276/2 "2020-06-30T19:16:57Z")

</div>

Are you using ansible to apply updates and reboot now? If so, what does your current process look like?

–john

---

<div class="post-metadata">

**Author:** ![Rafael\_Tomelin](https://avatars.discourse-cdn.com/v4/letter/r/da6949/32.png) [@Rafael\_Tomelin](https://forum.ansible.com/u/Rafael_Tomelin)\
**Post date:** [July 1, 2020, 10:36am UTC](https://forum.ansible.com/t/reboot-servers-strategy/33276/3 "2020-07-01T10:36:11Z")

</div>

Hi,

I get all servers from Azure and created inventory in memory by ansible.  
After get server and created inventory, connect in all servers collection facts and execute update of servers. This moment I need to create a process to reboot my servers by custom facts.

---

<div class="post-metadata">

**Author:** ![jcpetro](https://avatars.discourse-cdn.com/v4/letter/j/53a042/32.png) [@jcpetro](https://forum.ansible.com/u/jcpetro)\
**Post date:** [July 1, 2020, 6:36pm UTC](https://forum.ansible.com/t/reboot-servers-strategy/33276/4 "2020-07-01T18:36:53Z")

</div>

Hmm… I have seen where someone put a delay in the task that does the reboot. So you could probably do something like that, to make sure that the node is back up before moving on, or you could do some sort of check and register a variable, so that a node would only reboot if that node is set.

---

<div class="post-metadata">

**Author:** ![Moritz\_Kobel](https://avatars.discourse-cdn.com/v4/letter/m/b5ac83/32.png) [@Moritz\_Kobel](https://forum.ansible.com/u/Moritz_Kobel)\
**Post date:** [July 2, 2020, 11:19am UTC](https://forum.ansible.com/t/reboot-servers-strategy/33276/5 "2020-07-02T11:19:40Z")

</div>

Hi,

on our setup we reboot our servers groupwise.  
With serial: 1 is ensured only one server is rebooted a time.  
The reboot is only performed if /var/run/reboot-required exists. This  
might be Debian specific. This 'when' condition could give you an idea  
how to handle server specific facts.

--8\<--------------------------------  
- hosts:  
&nbsp;&nbsp;&nbsp;&nbsp;- sensu\_servers  
&nbsp;&nbsp;&nbsp;&nbsp;- build\_servers  
&nbsp;&nbsp;&nbsp;&nbsp;- db\_servers  
&nbsp;&nbsp;&nbsp;&nbsp;- lamp\_servers  
&nbsp;&nbsp;&nbsp;&nbsp;- app\_servers  
&nbsp;&nbsp;&nbsp;&nbsp;- mail\_servers  
&nbsp;&nbsp;&nbsp;&nbsp;- web\_servers  
&nbsp;&nbsp;become: true  
&nbsp;&nbsp;serial: 1  
&nbsp;&nbsp;tasks:  
&nbsp;&nbsp;&nbsp;&nbsp;- name: check if reboot-required exists  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;stat:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;path: /var/run/reboot-required  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;register: reboot\_required  
&nbsp;&nbsp;&nbsp;&nbsp;- name: reboot  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;reboot:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;when: reboot\_required.stat.exists  
--8\<--------------------------------

Check out the reboot module for further parameters like  
'post\_reboot\_delay' or 'test\_command':  
[https://docs.ansible.com/ansible/latest/modules/reboot\_module.html](https://docs.ansible.com/ansible/latest/modules/reboot_module.html)

I hope this helps.

-- Moritz
