# can ansible report if server needs restart (ubuntu && apt-get upgrade)

**URL:** <https://forum.ansible.com/t/can-ansible-report-if-server-needs-restart-ubuntu-apt-get-upgrade/15846>\
**Category:** Ansible Project\
**Tags:** ubuntu\
**Created:** [August 2, 2014, 10:40pm UTC](https://forum.ansible.com/t/can-ansible-report-if-server-needs-restart-ubuntu-apt-get-upgrade/15846 "2014-08-02T22:40:26Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Christian\_Schmitt](https://avatars.discourse-cdn.com/v4/letter/c/7cd45c/32.png) [@Christian\_Schmitt](https://forum.ansible.com/u/Christian_Schmitt)\
**Post date:** [August 2, 2014, 10:40pm UTC](https://forum.ansible.com/t/can-ansible-report-if-server-needs-restart-ubuntu-apt-get-upgrade/15846/1 "2014-08-02T22:40:26Z")

</div>

Currently i’m running a playbook against multiple servers, is there a way to print something if a server needs a reboot after an apt-get upgrade?  
i mean if the kernel gets upgraded i need to know which of them needs an restart.

is there a possible way that ansible could report such thing

---

<div class="post-metadata">

**Author:** ![drybjed](https://avatars.discourse-cdn.com/v4/letter/d/48db29/32.png) [@drybjed](https://forum.ansible.com/u/drybjed)\
**Post date:** [August 3, 2014, 3:55pm UTC](https://forum.ansible.com/t/can-ansible-report-if-server-needs-restart-ubuntu-apt-get-upgrade/15846/2 "2014-08-03T15:55:48Z")

</div>

Perhaps not the “Ansible way”, but you could install ‘update-notifer-common’ package and see if /var/run/reboot-required file is present - perhaps via nagios or cron + mail message.

[http://serverfault.com/questions/92932/how-does-ubuntu-keep-track-of-the-system-restart-required-flag-in-motd](http://serverfault.com/questions/92932/how-does-ubuntu-keep-track-of-the-system-restart-required-flag-in-motd)

[https://packages.debian.org/wheezy/update-notifier-common](https://packages.debian.org/wheezy/update-notifier-common)

Maciej

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [August 3, 2014, 4:16pm UTC](https://forum.ansible.com/t/can-ansible-report-if-server-needs-restart-ubuntu-apt-get-upgrade/15846/3 "2014-08-03T16:16:13Z")

</div>

That seems pretty darn reasonable to me.

The ansible stat module could be used to check for presense of that file at the end of the run, and reboot (and wait for SSH to come back up) if so desired.

---

<div class="post-metadata">

**Author:** ![Christian\_Schmitt](https://avatars.discourse-cdn.com/v4/letter/c/7cd45c/32.png) [@Christian\_Schmitt](https://forum.ansible.com/u/Christian_Schmitt)\
**Post date:** [August 3, 2014, 4:55pm UTC](https://forum.ansible.com/t/can-ansible-report-if-server-needs-restart-ubuntu-apt-get-upgrade/15846/4 "2014-08-03T16:55:10Z")

</div>

And what about yum based systems? I already made a working playbook with the apt upgrade and its really awesome. Finally a solution to drop out puppet (:

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [August 3, 2014, 6:30pm UTC](https://forum.ansible.com/t/can-ansible-report-if-server-needs-restart-ubuntu-apt-get-upgrade/15846/5 "2014-08-03T18:30:21Z")

</div>

It seems like it would be easy to execute something like

[http://serverfault.com/questions/122178/how-can-i-check-from-the-command-line-if-a-reboot-is-required-on-rhel-or-centos](http://serverfault.com/questions/122178/how-can-i-check-from-the-command-line-if-a-reboot-is-required-on-rhel-or-centos)

with the “script” module and key off the return code.
