# Waiting for host name to be resolvable

**URL:** <https://forum.ansible.com/t/waiting-for-host-name-to-be-resolvable/17368>\
**Category:** Ansible Project\
**Created:** [January 25, 2015, 1:36am UTC](https://forum.ansible.com/t/waiting-for-host-name-to-be-resolvable/17368 "2015-01-25T01:36:34Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yaroslav\_Tkachenko](https://avatars.discourse-cdn.com/v4/letter/y/dfb087/32.png) [@Yaroslav\_Tkachenko](https://forum.ansible.com/u/Yaroslav_Tkachenko)\
**Post date:** [January 25, 2015, 1:36am UTC](https://forum.ansible.com/t/waiting-for-host-name-to-be-resolvable/17368/1 "2015-01-25T01:36:34Z")

</div>

Hey guys,

I’m writing very simple task - I have a web app that I start and it takes a few minutes before it goes online. I thought it can be done like this:

- name: Waiting for the new environment to be online  
uri: url=http://SOME\_URL/api/heartbeat timeout=900  
async: 900  
poll: 10

But the problem is: SOME\_URL is not resolvable instantly, it’s a new DNS record. So task fails with the error “msg: Unable to resolve the host name given.”.  
Is there any way to solve this issue?

Thanks!

---

<div class="post-metadata">

**Author:** ![Lars\_Vonk](https://avatars.discourse-cdn.com/v4/letter/l/ec9cab/32.png) [@Lars\_Vonk](https://forum.ansible.com/u/Lars_Vonk)\
**Post date:** [January 28, 2015, 1:51pm UTC](https://forum.ansible.com/t/waiting-for-host-name-to-be-resolvable/17368/2 "2015-01-28T13:51:13Z")

</div>

How is the DNS record created?

---

<div class="post-metadata">

**Author:** ![Edgars](https://avatars.discourse-cdn.com/v4/letter/e/f17d59/32.png) [@Edgars](https://forum.ansible.com/u/Edgars)\
**Post date:** [January 28, 2015, 2:51pm UTC](https://forum.ansible.com/t/waiting-for-host-name-to-be-resolvable/17368/3 "2015-01-28T14:51:45Z")

</div>

How about wait\_for?

```auto

- wait_for: host=SOME_URL port=80 delay=20 state=started

```

Edgars

svētdiena, 2015. gada 25. janvāris 02:36:35 UTC+1, Yaroslav Tkachenko rakstīja:

---

<div class="post-metadata">

**Author:** ![Giovanni\_Tirloni](https://avatars.discourse-cdn.com/v4/letter/g/71c47a/32.png) [@Giovanni\_Tirloni](https://forum.ansible.com/u/Giovanni_Tirloni)\
**Post date:** [January 28, 2015, 3:11pm UTC](https://forum.ansible.com/t/waiting-for-host-name-to-be-resolvable/17368/4 "2015-01-28T15:11:52Z")

</div>

It fits this situation perfectly because wait\_for will keep trying to  
resolve the DNS name over and over (and not just once when it starts).

Regarding the application itself being up, let me suggest a subsequent  
check with get\_url module (this one doesn't keep trying to resolve the  
hostname many times, so wait\_for is really required).

Giovanni
