Created
June 23, 2016 16:46
-
-
Save OldCrowEW/635dc25f952cc395f8de06b822b199a7 to your computer and use it in GitHub Desktop.
anisble update host and reboot if kernel updated
This file contains 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: yum update | |
yum: name=* state=latest | |
- name: Check for reboot hint. | |
shell: if [ `rpm -q 'kernel' |sort --version-sort -r | head -n 1 | awk '{print $1}' | head -n 1` != kernel-`uname -r` ]; then echo "reboot"; else echo "no"; fi | |
register: reboot_hint | |
always_run: yes | |
- name: Rebooting ... | |
shell: sleep 2 && shutdown -r now "yum kernel update applied" | |
when: reboot_hint.stdout.find('reboot') != -1 | |
async: 1 | |
poll: 0 | |
ignore_errors: true | |
- name: Wait for server to restart | |
local_action: wait_for host={{ inventory_hostname }} port=22 delay=1 timeout=300 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment