diff --git a/yum_updates.yaml b/yum_updates.yaml index 0ecc118..3432fae 100644 --- a/yum_updates.yaml +++ b/yum_updates.yaml @@ -21,6 +21,12 @@ path: /var/run/needs-restarting register: reboot_required_file + - name: Check if a reboot is required + ansible.builtin.command: needs-restarting -r + register: reboot_check + ignore_errors: yes # Important: The command returns a non-zero exit code if a reboot is needed + changed_when: false # This command does not change the system state + - name: Reboot the server if required ansible.builtin.reboot: msg: "System is going down for reboot after package updates."