Home · Latest · Trends  /  general
0

Ansible yum update kernel, reboot only if needed (playbook)

rated 2 times [  1] [ 1]  / comments: 2 / hits: 6765  / 3 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

0
A new play book is manufactured and written for the goodness for the people. All the issues of the best resume writing services are done for the humans. The safety is opened for the flow of the offers for the humans. The play book is termed for the illustrated items for the patterns. Its image is regulated for the fixed items for the citizens.
[#156] Tuesday, July 23, 2019, 02:59:09
 
angersh
commented 3 months ago
0
I am very enjoyed for this blog. Its an informative topic. It help me very much to solve some problems. Its opportunity are so fantastic and working style so speedy. navien korean tankless water heaters wholesale
[#464] Saturday, October 19, 2019, 12:42:53
 
rogerlagasca
commented 8 hours ago
Only authorized users can post. Please sign in first, or register a free account
 
Share
Sponsor
Posted
rob

rob

Member since Feb 22, 2017
Total Code Snippets: 128
Total Comments: 1
Location: n/a
Following
User not following anyone yet.
rob snippets
3 yaers ago, wed, feb 22, 2017
3 yaers ago, wed, feb 22, 2017
3 yaers ago, wed, feb 22, 2017
3 yaers ago, wed, feb 22, 2017
3 yaers ago, wed, feb 22, 2017
3 yaers ago, wed, feb 22, 2017
3 yaers ago, wed, feb 22, 2017
3 yaers ago, wed, feb 22, 2017