Created
September 20, 2017 15:24
-
-
Save adaiguoguo/0ac04cbf495e98ee47bfbbcb640febbb to your computer and use it in GitHub Desktop.
ansible-upgrade-kernel
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- 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