forked from beniaris-zz/system_administration
-
Notifications
You must be signed in to change notification settings - Fork 0
/
reboot-and-wait.yml
35 lines (32 loc) · 877 Bytes
/
reboot-and-wait.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
---
# Reboot and wait for system to come online
#
# Outline:
# 1. Reboot RHEL Guest
# 2. Wait for reboot to complete
#
# Note: This can all be done with the reboot module in Ansible 2.7 within a single task. This shows the
# method prior to the reboot module
#
- name: Reboot host and wait for it to come back online
hosts: all
gather_facts: no
become: yes
tasks:
- name: Restart the system
shell: sleep 2 && shutdown -r now "Reboot post patching via Ansible"
async: 1
poll: 0
ignore_errors: true
- name: Wait for the server to resume operation
wait_for:
host: "{{ inventory_hostname }}"
port: 22
state: started
delay: 25
timeout: 200
become: false
delegate_to: localhost
- name: Invoke Ping module on the host to verify that it is up
ping:
...