Last active
May 9, 2018 07:46
-
-
Save silviot/815c72caa9da8238c7c4d542d4fa72a6 to your computer and use it in GitHub Desktop.
Reboot server and wait for restart with ansible
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
# After way too many attempts, this one seems to really work all the time | |
- name: Reboot server | |
shell: sleep 2 && reboot | |
async: 1 | |
poll: 0 | |
failed_when: false | |
become: true | |
- name: Wait for server to initiate shutdown | |
wait_for: | |
host: "{{ ansible_ssh_host }}" | |
state: stopped | |
port: 22 | |
delegate_to: localhost | |
- name: Wait for server to come back online | |
wait_for: | |
host: "{{ ansible_ssh_host }}" | |
state: started | |
port: 22 | |
delegate_to: localhost |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment