DevOps Blog - Nicolas Paris

Check if a restart is needed with Ansible

Ansible

If a restart is needed in a Linux instance, it will add a file in /var/run/reboot-required
It contains the message "System restart required".

Let's check if the file is there with ansible!

- name: Check if restart is required
hosts: all
tasks:
- name: Check that the reboot-requied exists
stat:
path: /var/run/reboot-required
register: p
- debug:
msg: "Reboot required"
when: p.stat.exists

Done.