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 |
Zack Williams | 709f11b | 2016-03-17 14:29:51 -0700 | [diff] [blame] | 5 | - name: restart host |
Zack Williams | a9421e2 | 2016-03-02 13:53:37 -0700 | [diff] [blame] | 6 | shell: sleep 2 && shutdown -r now "Ansible updates triggered" |
| 7 | async: 1 |
| 8 | poll: 0 |
| 9 | ignore_errors: true |
| 10 | |
Zack Williams | 709f11b | 2016-03-17 14:29:51 -0700 | [diff] [blame] | 11 | # wait 1m, then try to contact machine for 10m |
| 12 | - name: wait for host |
Zack Williams | a9421e2 | 2016-03-02 13:53:37 -0700 | [diff] [blame] | 13 | become: false |
| 14 | local_action: |
| 15 | wait_for host={{ inventory_hostname }} |
| 16 | port=22 |
Zack Williams | 709f11b | 2016-03-17 14:29:51 -0700 | [diff] [blame] | 17 | delay=60 timeout=600 |
Zack Williams | a9421e2 | 2016-03-02 13:53:37 -0700 | [diff] [blame] | 18 | state=started |
| 19 | |