# Rebooting the server

**URL:** <https://forum.ansible.com/t/rebooting-the-server/14885>\
**Category:** Ansible Project\
**Created:** [March 28, 2014, 2:00pm UTC](https://forum.ansible.com/t/rebooting-the-server/14885 "2014-03-28T14:00:28Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rafal\_Hajduk](https://avatars.discourse-cdn.com/v4/letter/r/35a633/32.png) [@Rafal\_Hajduk](https://forum.ansible.com/u/Rafal_Hajduk)\
**Post date:** [March 28, 2014, 2:00pm UTC](https://forum.ansible.com/t/rebooting-the-server/14885/1 "2014-03-28T14:00:28Z")

</div>

Hello

I want to reboot my server and continue with other instructions. My code is:

`

- name: reboot  
command: reboot  
notify:

- wait until rebooted

- name: wait until rebooted  
local\_action: wait\_for host={{ansible\_fqdn}} port=22 state=started delay=30  
sudo: false  
`

After execution I get an error:

> failed: [xxx] =\> {“elapsed”: 300, “failed”: true, “item”: “”}  
> msg: Timeout when waiting for myhostname:22
> 
> FATAL: all hosts have already failed – aborting

How can I fix it?

---

<div class="post-metadata">

**Author:** ![Brian\_Green](https://avatars.discourse-cdn.com/v4/letter/b/e495f1/32.png) [@Brian\_Green](https://forum.ansible.com/u/Brian_Green)\
**Post date:** [March 28, 2014, 3:13pm UTC](https://forum.ansible.com/t/rebooting-the-server/14885/2 "2014-03-28T15:13:27Z")

</div>

If the server is taking a longer than the default timeout value, increase that value. Default is 300 seconds, might need to increase that.

[http://docs.ansible.com/wait\_for\_module.html](http://docs.ansible.com/wait_for_module.html)

Or there could be a connectivity issue. Is it listening on port 22? Does FQDN name resolution work?

---

<div class="post-metadata">

**Author:** ![Rafal\_Hajduk](https://avatars.discourse-cdn.com/v4/letter/r/35a633/32.png) [@Rafal\_Hajduk](https://forum.ansible.com/u/Rafal_Hajduk)\
**Post date:** [March 28, 2014, 3:28pm UTC](https://forum.ansible.com/t/rebooting-the-server/14885/3 "2014-03-28T15:28:06Z")

</div>

The server reboots very quickly (10-15 seconds), so timeout is not the issue.

However the problem might be the FQDN name. I used it because I found it in some Ansible snippet.

Which variable should I place there in order to get current host rebooted? (in my case it would be xxx)

My hosts file:  
[xxx]  
xxx

W dniu piątek, 28 marca 2014 16:13:27 UTC+1 użytkownik Brian Green napisał:

---

<div class="post-metadata">

**Author:** ![Brian\_Green](https://avatars.discourse-cdn.com/v4/letter/b/e495f1/32.png) [@Brian\_Green](https://forum.ansible.com/u/Brian_Green)\
**Post date:** [March 28, 2014, 3:53pm UTC](https://forum.ansible.com/t/rebooting-the-server/14885/4 "2014-03-28T15:53:42Z")

</div>

What entry is in your inventory host file? Is it IP address, short hostname, fqdn?

The following variables are valid in your playbook, and the ‘right’ one depends on your environment.  
ansible\_fqdn, ansible\_hostname, inventory\_hostname, inventory\_hostname\_short

The ansible\_fqdn and ansible\_hostname are facts determined at the remote host. Inventory\_hostname and inventory\_hostname\_short are parsed from your Ansible inventory file.  
For instance, in your current playbook, if you have an entry for the reboot target of dbserver, and for some reason the ‘dbserver’ node reports its fqdn as [webserver.example.org](http://webserver.example.org) then your reboot command will wait for [webserver.example.org:22](http://webserver.example.org:22) to be available, which may not resolve from your Ansible management node.

Given that Ansible has no problem connecting using the value in your inventory file, you might start with inventory\_hostname which will use the entry in your inventory file.

Relevant docs here: [http://docs.ansible.com/playbooks\_variables.html](http://docs.ansible.com/playbooks_variables.html)
