Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
ansible-upgrade-kernel
- name: Check for reboot hint.
shell: LAST_KERNEL=$(rpm -q --last kernel | perl -pe 's/^kernel-(\S+).*/$1/' | head -1);CURRENT_KERNEL=$(uname -r); if [ $LAST_KERNEL != $CURRENT_KERNEL ]; then echo 'reboot'; else echo 'no'; fi
ignore_errors: true
register: reboot_hint
- name: Rebooting ...
shell: sleep 2 && /usr/sbin/reboot
async: 1
poll: 0
ignore_errors: true
when: reboot_hint.stdout.find("reboot") != -1
- name: Wait for host to boot
become: false
local_action: wait_for
args:
host: "{{ inventory_hostname }}"
port: 22
state: started
delay: 30
timeout: 180
when: reboot_hint.stdout.find("reboot") != -1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.