Update playbooks/check-reboot-needed.yml

This commit is contained in:
2025-07-04 18:46:35 +00:00
parent b04044255c
commit 49d645f2df

View File

@@ -2,6 +2,9 @@
hosts: all hosts: all
gather_facts: false gather_facts: false
become: true become: true
vars:
reboot_machines: false # default, override via --extra-vars
tasks: tasks:
- name: Check for /var/run/reboot-required - name: Check for /var/run/reboot-required
stat: stat:
@@ -11,3 +14,11 @@
- name: Display reboot status - name: Display reboot status
debug: debug:
msg: "{{ inventory_hostname }} {{ 'REQUIRES' if reboot_flag.stat.exists else 'does NOT require' }} a reboot." msg: "{{ inventory_hostname }} {{ 'REQUIRES' if reboot_flag.stat.exists else 'does NOT require' }} a reboot."
- name: Reboot if required and reboot_machines flag is true
reboot:
msg: "Rebooting due to /var/run/reboot-required"
pre_reboot_delay: 5
when:
- reboot_flag.stat.exists
- reboot_machines | bool