tasks file for reboot_host
Reboot a node
-
name: Reboot host
shell: ( sleep 5 && /sbin/shutdown -r now “Reboot triggered by Ansible” & )
async: 1
poll: 0
ignore_errors: true
become: true
register: host_reboot -
set_fact:
role_name1: “{{ role_path | basename }}”
register_out: “{{ host_reboot }}” -
set_fact:
register_out_log: “{{ register_out }}” -
name: Display hosts being rebooted
debug:
msg: “Waiting for host <{{ inventory_hostname }}> to reboot”
when: host_reboot.changed -
name: Wait for host to boot
wait_for_connection:
connect_timeout: 20
sleep: 5
delay: 5
timeout: 600
ignore_errors: yes
when: host_reboot is changed
register: wait_for_host_to_boot -
name: Debug wait for reboot
debug:
msg: “{{ wait_for_host_to_boot }}” -
name: Verify ssh connection to host
local_action: wait_for
args:
host: “{{ inventory_hostname }}”
port: 22
delay: 5
sleep: 1
connect_timeout: 5
timeout: 600
search_regex: OpenSSH
become: false
when: wait_for_host_to_boot is succeeded
register: host_ssh_test -
name: Get host’s name to verify host is running
command: hostname
register: hostname_output
when: host_ssh_test is succeeded -
name: Display host’s name
debug:
msg: “Host <{{ hostname_output.stdout_lines[0] }}> has rebooted”
when: hostname_output.changed
after executing this task it is continuously hanged at TASK [reboot_host_normal : Wait for host to boot]
plz help me how to come out after 10 mins waiting time.