0
Ansible yum update kernel, reboot only if needed (playbook)
rated 2 times
[
1]
[
1]
/ comments: 0 / hits: 4555
/ 2 yaers ago, wed, may 3, 2017, 15:07:32
I pieced this playbook together from multiple snippets from various playbooks on the internet.. have tried it w/ a testbed of CentOS 6 and 7 hosts all at once and can say it works in my environment.
- hosts: all
become: false
tasks:
- name: upgrade the kernel
yum: name=kernel state=latest
- name: Check for reboot
shell: if [ $(rpm -q kernel|tail -n 1) != kernel-$(uname -r) ]; then echo 'reboot'; else echo 'no'; fi
ignore_errors: true
register: reboot_hint
- name: Rebooting ...
command: shutdown -r now "Reboot required for updated kernel"
async: 0
poll: 0
become: false
ignore_errors: true
when: reboot_hint.stdout.find("reboot") != -1
register: rebooting
- name: Wait for rebooted servers to come back
local_action: wait_for host={{ ansible_ssh_host | default(inventory_hostname) }} state=started port=22 delay=30 timeout=300 connect_timeout=15
when: rebooting|changed
More From
» general
Comments
There are no comments for this Snippet yet
Only authorized users can post. Please sign in first, or register a free account