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

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

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

https://packages.debian.org/wheezy/update-notifier-common

Maciej

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.

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 (:

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

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