Created
September 23, 2016 09:57
-
-
Save benfairless/f9e03fc282370dba92f99d5fa91362e7 to your computer and use it in GitHub Desktop.
Automagical patching
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
--- | |
- 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