Zack Williams | a9421e2 | 2016-03-02 13:53:37 -0700 | [diff] [blame] | 1 | --- |
Zack Williams | 5223dd9 | 2017-02-28 23:38:02 -0700 | [diff] [blame] | 2 | # file: common-prep/handlers/main.yml |
Zack Williams | a9421e2 | 2016-03-02 13:53:37 -0700 | [diff] [blame] | 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 | 5223dd9 | 2017-02-28 23:38:02 -0700 | [diff] [blame] | 6 | shell: > |
| 7 | sleep 2 && shutdown -r now "Ansible updates triggered" |
Zack Williams | a9421e2 | 2016-03-02 13:53:37 -0700 | [diff] [blame] | 8 | async: 1 |
| 9 | poll: 0 |
| 10 | ignore_errors: true |
| 11 | |
Zack Williams | 709f11b | 2016-03-17 14:29:51 -0700 | [diff] [blame] | 12 | # wait 1m, then try to contact machine for 10m |
| 13 | - name: wait for host |
Zack Williams | a9421e2 | 2016-03-02 13:53:37 -0700 | [diff] [blame] | 14 | become: false |
| 15 | local_action: |
Zack Williams | 5223dd9 | 2017-02-28 23:38:02 -0700 | [diff] [blame] | 16 | wait_for |
| 17 | host={{ inventory_hostname }} |
Zack Williams | a9421e2 | 2016-03-02 13:53:37 -0700 | [diff] [blame] | 18 | port=22 |
Zack Williams | 5223dd9 | 2017-02-28 23:38:02 -0700 | [diff] [blame] | 19 | search_regex=OpenSSH |
| 20 | delay=60 |
| 21 | timeout=600 |
Zack Williams | a9421e2 | 2016-03-02 13:53:37 -0700 | [diff] [blame] | 22 | |