# Need help to automate tasks.

**URL:** <https://forum.ansible.com/t/need-help-to-automate-tasks/25839>\
**Category:** Ansible Project\
**Created:** [October 27, 2017, 10:55am UTC](https://forum.ansible.com/t/need-help-to-automate-tasks/25839 "2017-10-27T10:55:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![abhay\_gupta](https://avatars.discourse-cdn.com/v4/letter/a/d6d6ee/32.png) [@abhay\_gupta](https://forum.ansible.com/u/abhay_gupta)\
**Post date:** [October 27, 2017, 10:55am UTC](https://forum.ansible.com/t/need-help-to-automate-tasks/25839/1 "2017-10-27T10:55:37Z")

</div>

Hello Friends,

I need your help to finish my task.

In my playbook, we are starting a web server which took almost 4-7 minutes.  
I need to write a task, in which we need to hit a wsdl in after 1 minute and if we are getting the 200 response message as a response. need to print a message" Web server is up and running".  
And if after some time, let’s say till 10 minutes if the wsdl is not getting the 200 response message, it should say, “Web server is not correctly deployed.”

Thanks.  
Abhay.

---

<div class="post-metadata">

**Author:** ![j.r.hawkesworth](https://avatars.discourse-cdn.com/v4/letter/j/a3d4f5/32.png) [@j.r.hawkesworth](https://forum.ansible.com/u/j.r.hawkesworth)\
**Post date:** [October 29, 2017, 9:34am UTC](https://forum.ansible.com/t/need-help-to-automate-tasks/25839/2 "2017-10-29T09:34:19Z")

</div>

You can do something like this (thanks to Matt Martz who originally suggested it)

- name: check if app is up and ready to serve the wsdl  
uri:  
url: ‘http://{{ inventory\_hostname }}/app/app.wsdl’  
return\_content: yes  
timeout: 2  
delegate\_to: localhost  
register: poll\_result  
until: poll\_result[‘status’]|default(0) == 200  
retries: 40  
delay: 3

This tries the url every 3 seconds for a maximum of 40 attempts.

Hope this helps,

Jon

---

<div class="post-metadata">

**Author:** ![j.r.hawkesworth](https://avatars.discourse-cdn.com/v4/letter/j/a3d4f5/32.png) [@j.r.hawkesworth](https://forum.ansible.com/u/j.r.hawkesworth)\
**Post date:** [October 29, 2017, 9:37am UTC](https://forum.ansible.com/t/need-help-to-automate-tasks/25839/3 "2017-10-29T09:37:20Z")

</div>

Oh, I meant to say you can use the block…rescue … allways with ‘debug’ module to display the messages you want.

See [http://docs.ansible.com/ansible/latest/playbooks\_blocks.html](http://docs.ansible.com/ansible/latest/playbooks_blocks.html)  
and [http://docs.ansible.com/ansible/latest/debug\_module.html](http://docs.ansible.com/ansible/latest/debug_module.html)

Jon

---

<div class="post-metadata">

**Author:** ![abhay\_gupta](https://avatars.discourse-cdn.com/v4/letter/a/d6d6ee/32.png) [@abhay\_gupta](https://forum.ansible.com/u/abhay_gupta)\
**Post date:** [October 30, 2017, 7:43am UTC](https://forum.ansible.com/t/need-help-to-automate-tasks/25839/4 "2017-10-30T07:43:31Z")

</div>

Thanks Jon…  
I am able to complete my task now…

Abhay Gupta…
