# TASK \[reboot\_host\_normal : Reboot host\] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* changed: \[x.x.x.x\] TASK \[reboot\_host\_normal : set\_fact\] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* ok: \[x.x.x.x\] TASK \[reboot\_host\_normal : set\_fact\] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* ok: \[x.x.x.x\] TASK

**URL:** <https://forum.ansible.com/t/task-reboot-host-normal-reboot-host-changed-x-x-x-x-task-reboot-host-normal-set-fact-ok-x-x-x-x-task-reboot-host-normal-set-fact-ok-x-x-x-x-task/10319>\
**Category:** Get Help\
**Tags:** playbook, ansible-core\
**Created:** [October 16, 2024, 6:40am UTC](https://forum.ansible.com/t/task-reboot-host-normal-reboot-host-changed-x-x-x-x-task-reboot-host-normal-set-fact-ok-x-x-x-x-task-reboot-host-normal-set-fact-ok-x-x-x-x-task/10319 "2024-10-16T06:40:36Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![iluagk](https://avatars.discourse-cdn.com/v4/letter/i/49beb7/32.png) [@iluagk](https://forum.ansible.com/u/iluagk)\
**Post date:** [October 16, 2024, 6:40am UTC](https://forum.ansible.com/t/task-reboot-host-normal-reboot-host-changed-x-x-x-x-task-reboot-host-normal-set-fact-ok-x-x-x-x-task-reboot-host-normal-set-fact-ok-x-x-x-x-task/10319/1 "2024-10-16T06:40:36Z")

</div>

* * *

# 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.

---

<div class="post-metadata">

**Author:** ![jpmens](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/jpmens/32/5543_2.png) [@jpmens](https://forum.ansible.com/u/jpmens)\
**Post date:** [October 16, 2024, 7:03am UTC](https://forum.ansible.com/t/task-reboot-host-normal-reboot-host-changed-x-x-x-x-task-reboot-host-normal-set-fact-ok-x-x-x-x-task-reboot-host-normal-set-fact-ok-x-x-x-x-task/10319/2 "2024-10-16T07:03:14Z")

</div>

do you really expect anybody to attempt to decipher the mess spread over title and body which hasn’t even a modicum of formatting on it?

---

<div class="post-metadata">

**Author:** ![iluagk](https://avatars.discourse-cdn.com/v4/letter/i/49beb7/32.png) [@iluagk](https://forum.ansible.com/u/iluagk)\
**Post date:** [October 16, 2024, 7:06am UTC](https://forum.ansible.com/t/task-reboot-host-normal-reboot-host-changed-x-x-x-x-task-reboot-host-normal-set-fact-ok-x-x-x-x-task-reboot-host-normal-set-fact-ok-x-x-x-x-task/10319/3 "2024-10-16T07:06:16Z")

</div>

Actually my task is hanged here. How to over come from this.  
Actually this in properindentation in my plabook. At the time of copy pasting time indentation is missing.

---

<div class="post-metadata">

**Author:** ![dnmvisser](https://avatars.discourse-cdn.com/v4/letter/d/8e8cbc/32.png) [@dnmvisser](https://forum.ansible.com/u/dnmvisser)\
**Post date:** [October 16, 2024, 3:27pm UTC](https://forum.ansible.com/t/task-reboot-host-normal-reboot-host-changed-x-x-x-x-task-reboot-host-normal-set-fact-ok-x-x-x-x-task-reboot-host-normal-set-fact-ok-x-x-x-x-task/10319/4 "2024-10-16T15:27:45Z")

</div>

Instead of reinventing wheels and shell pipes, why not use the reboot module and be done with it?  
[https://docs.ansible.com/ansible/latest/collections/ansible/builtin/reboot\_module.html](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/reboot_module.html)

---

<div class="post-metadata">

**Author:** ![shertel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/shertel/32/1241_2.png) [@shertel](https://forum.ansible.com/u/shertel)\
**Post date:** [October 16, 2024, 5:38pm UTC](https://forum.ansible.com/t/task-reboot-host-normal-reboot-host-changed-x-x-x-x-task-reboot-host-normal-set-fact-ok-x-x-x-x-task-reboot-host-normal-set-fact-ok-x-x-x-x-task/10319/5 "2024-10-16T17:38:15Z")

</div>

You can use triple backticks (```) on the line before and after a block of YAML to preserve the format:

```auto
- 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

```

Not sure if this is the issue you’re experiencing, but if you’re using interpreter discovery, `wait_for_connection` uses the original discovered interpreter after reboot, instead of trying to rediscover it. If the previous interpreter no longer exists, that would cause a timeout (also reported as an issue here [wait\_for\_connection does not discover new python interpreter after reboot · Issue #82804 · ansible/ansible · GitHub](https://github.com/ansible/ansible/issues/82804)).
