Handle freshness for all 3 types separately

If microcode was missing, checking the other two would be UNKN and thus
not restart. But, if microcode *is* present, we want to restart for
either of the other two as well.

So separate into 3 distinct checks and restart if any one is changed.
This commit is contained in:
Joshua Boniface 2023-10-03 13:42:11 -04:00
parent c11f896a60
commit 7fe682aa60
1 changed files with 17 additions and 5 deletions

View File

@ -59,10 +59,22 @@
gather_facts: yes
serial: 1
tasks:
- name: check freshness
command: /usr/sbin/needrestart -p
register: freshness
changed_when: freshness.rc >= 1 and freshness.rc < 3
- name: check freshness (kernel)
command: /usr/sbin/needrestart -p -k
register: freshness_kernel
changed_when: freshness_kernel.rc >= 1 and freshness_kernel.rc < 3
failed_when: false
- name: check freshness (libraries)
command: /usr/sbin/needrestart -p -l
register: freshness_libraries
changed_when: freshness_libraries.rc >= 1 and freshness_libraries.rc < 3
failed_when: false
- name: check freshness (microcode)
command: /usr/sbin/needrestart -p -w
register: freshness_microcode
changed_when: freshness_microcode.rc >= 1 and freshness_microcode.rc < 3
failed_when: false
- name: restart system cleanly
@ -205,7 +217,7 @@
- name: reset any systemd failures
command: systemctl reset-failed
when: freshness.changed
when: freshness_kernel.changed or freshness_libraries.changed or freshness_microcode.changed
- name: wait 30 seconds for system to stabilize
pause: