Skip to content

Instantly share code, notes, and snippets.

@nixcraft
Created June 2, 2020 08:03
Show Gist options
  • Save nixcraft/66f3773d1f68f178b5b3ca8c4258cbe9 to your computer and use it in GitHub Desktop.
Save nixcraft/66f3773d1f68f178b5b3ca8c4258cbe9 to your computer and use it in GitHub Desktop.
Ansible reboot all servers except two database servers
- name: Check if a reboot is needed on all Ubuntu/Debian based servers
register: reboot_required_file
stat: path=/var/run/reboot-required get_md5=no
- name: Reboot the box if kernel updated
reboot:
msg: "Reboot initiated by Ansible for kernel updates"
connect_timeout: 5
reboot_timeout: 300
pre_reboot_delay: 0
post_reboot_delay: 30
test_command: uptime
when: reboot_required_file.stat.exists and ( inventory_hostname != "aws-db1" and inventory_hostname != "aws-db2" )
@nixcraft
Copy link
Author

nixcraft commented Jun 2, 2020

@mainboarder

yes, much better to read. Thanks, mate!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment