Skip to content

Instantly share code, notes, and snippets.

@benfairless
Created September 23, 2016 09:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benfairless/f9e03fc282370dba92f99d5fa91362e7 to your computer and use it in GitHub Desktop.
Save benfairless/f9e03fc282370dba92f99d5fa91362e7 to your computer and use it in GitHub Desktop.
Automagical patching
---
- hosts: all
serial: 4
tasks:
- name: gather information on services not currently running
sudo: true
shell: systemctl | grep failed > pre.log
- name: patch all yum packages
sudo: true
yum: name=* state=latest
- name: restart machine
sudo: true
shell: sync && shutdown -r now "Rebooting as part of patching process"
- name: wait for server to return
local_action: wait_for host={{ inventory_hostname }} state=started delay=30 timeout=300
- name: gather information on service not running post-patch
sudo: true
shell: systemctl | grep failed > post.log
- name: check pre and post running services
sudo: true
shell: [[ $(diff pre.log post.log | wc -l) -gt 0 ]] && exit 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment