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

3 yaers ago, Wed, May 3, 2017, 15:07:32
- 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

Comments

angersh
commented 4 months ago, Tue, Jul 23, 2019, 02:59:09
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.
rogerlagasca
commented 3 weeks ago, Sat, Oct 19, 2019, 12:42:53
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
rogerlagasca
commented 3 weeks ago, Tue, Oct 22, 2019, 08:42:28
Admiring the time and effort you put into your blog and detailed information you offer!.. <a href="The-Ultimate-Buying-Guide-.html">best tankless water heater</a>