Waiting for host name to be resolvable

776 views
Skip to first unread message

Yaroslav Tkachenko

unread,
Jan 24, 2015, 8:36:35 PM1/24/15
to ansible...@googlegroups.com
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!

Lars Vonk

unread,
Jan 28, 2015, 8:51:13 AM1/28/15
to ansible...@googlegroups.com
How is the DNS record created?

Edgars

unread,
Jan 28, 2015, 9:51:45 AM1/28/15
to ansible...@googlegroups.com
How about wait_for?

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

Edgars

Giovanni Tirloni

unread,
Jan 28, 2015, 10:12:01 AM1/28/15
to ansible...@googlegroups.com
On Wed, 28 Jan 2015 06:51 -0800, Edgars <edgars...@gmail.com> wrote:
> How about wait_for?

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
Reply all
Reply to author
Forward
0 new messages