Zack Williams | a9421e2 | 2016-03-02 13:53:37 -0700 | [diff] [blame] | 1 | --- |
| 2 | # file: roles/common-prep/handlers/main.yml |
| 3 | |
| 4 | # from https://support.ansible.com/hc/en-us/articles/201958037-Reboot-a-server-and-wait-for-it-to-come-back |
| 5 | - name: restart machine |
| 6 | shell: sleep 2 && shutdown -r now "Ansible updates triggered" |
| 7 | async: 1 |
| 8 | poll: 0 |
| 9 | ignore_errors: true |
| 10 | |
| 11 | # wait 1m, then try to contact machine for 5m |
| 12 | - name: wait for machine |
| 13 | become: false |
| 14 | local_action: |
| 15 | wait_for host={{ inventory_hostname }} |
| 16 | port=22 |
| 17 | delay=60 timeout=300 |
| 18 | state=started |
| 19 | |