Created
March 10, 2019 16:10
-
-
Save nccurry/8a3a8edb53b70d8527ba569dbc7d668e to your computer and use it in GitHub Desktop.
Reboot ansible host after package update
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
- name: Update/reboot host | |
gather_facts: false | |
become: true | |
tasks: | |
- name: Update system packages | |
yum: | |
name: '*' | |
state: latest | |
register: yum_update | |
retries: 5 | |
delay: 1 | |
until: yum_update.rc == 0 | |
- name: Reboot server on update | |
block: | |
- name: Reboot server | |
shell: sleep 10 && /sbin/shutdown -r now "System packages updated" | |
async: 300 | |
poll: 0 | |
become: true | |
- name: Wait for system to reboot | |
wait_for_connection: | |
connect_timeout: 20 | |
sleep: 5 | |
delay: 20 | |
timeout: 300 | |
when: yum_update.changed |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment