I'm using Ansible to check hosts if they need to be rebooted if the /vmlinuz
kernel doesn't resolve to uname -r
.
The if
condition is although always identifing a reboot even though the test machine has been rebooted and the kernel is resolving to the same kernel:
if [ $(readlink -f /vmlinuz) != /boot/vmlinuz-$(uname -r) ]; then echo 'reboot'; else echo 'no'; fi
- name: Check for reboot hint.
shell: if [ $(readlink -f /vmlinuz) != /boot/vmlinuz-$(uname -r) ]; then echo 'reboot'; else echo 'no'; fi
ignore_errors: true
register: reboot_hint
- name: Rebooting ...
command: shutdown -r now "Ansible kernel update applied"
async: 0
poll: 0
ignore_errors: true
when: kernelup|changed or reboot_hint.stdout.find("reboot") != -1
register: rebooting
- name: Wait for thing to reboot...
pause: seconds=45
when: rebooting|changed
kernelup
?kernelup|changed
in my yaml file. I assume it has to do with the wait for thing to reboot.../vmlinuz
exists and points to the latest kernel. This is not a reasonable assumption, as on most distributions there is no such thing, and even on the oddball distributions which do have it, it may or may not even be present or kept up to date.