Need help to automate tasks.

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.

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

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
and http://docs.ansible.com/ansible/latest/debug_module.html

Jon

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

Abhay Gupta…