add new logic to detect whether rebooting is necessary or not

This commit is contained in:
Lukas Greve
2025-10-24 14:59:15 +02:00
parent 058db5096a
commit f1636e1eec

View File

@@ -10,8 +10,28 @@
state: latest state: latest
update_cache: yes update_cache: yes
- name: Force reboot after updates (safe for Rocky Linux) - name: Check if reboot required (RedHat/CentOS)
command: needs-restarting -r
register: needs_restarting_output
changed_when: false
ignore_errors: true
when: ansible_os_family == "RedHat"
- name: Check if reboot required (Debian/Ubuntu)
stat:
path: /var/run/reboot-required
register: reboot_required_file
when: ansible_os_family != "RedHat"
- name: Reboot if required (RedHat/CentOS)
reboot: reboot:
msg: "System reboot after package updates" when:
post_reboot_delay: 10 - ansible_os_family == "RedHat"
timeout: 300 - needs_restarting_output.rc == 1
- needs_restarting_output is defined
- name: Reboot if required (Debian/Ubuntu)
reboot:
when:
- ansible_os_family != "RedHat"
- reboot_required_file.stat.exists == true