Here's how we wait for some of our tomcat apps to start up:
- name: check every 3 seconds for 40 attempts if tomcat is up and ready to
serve the healthcheck page
uri:
url: 'http://{{ inventory_hostname }}/app/healthcheck.jsp'
return_content: yes
timeout: 2
delegate_to: localhost
register: tomcat_result
until: tomcat_result['status']|default(0) == 200
retries: 40
delay: 3
You would need to experiment with the number of retries. If I recall
tomcat locks the port long before it starts responding on it, so its good
to check that the app has completed coming up and can actually server some
kind of content.
We started out with configured wait periods for each environment but prefer
the above as the playbook can proceed as soon as the application is ready
to serve requests.
I guess you could have 3 plays in your playbook and in each one check the
relevant group of tomcats
- hosts: batch
tasks:
- name: check batch tomcats are up
uri:
url: 'http://{{ inventory_hostname }}/app/healthcheck.jsp'
return_content: yes
timeout: 2
delegate_to: localhost
register: tomcat_result
until: tomcat_result['status']|default(0) == 200
retries: 40
delay: 3
- hosts: webtier
tasks:
- name: check webtier tomcats are up
uri:
url: 'http://{{ inventory_hostname }}/app/healthcheck.jsp'
return_content: yes
timeout: 2
delegate_to: localhost
register: tomcat_result
until: tomcat_result['status']|default(0) == 200
retries: 40
delay: 3
- hosts: backend
tasks:
- name: check backend tomcats are up
uri:
url: 'http://{{ inventory_hostname }}/app/healthcheck.jsp'
return_content: yes
timeout: 2
delegate_to: localhost
register: tomcat_result
until: tomcat_result['status']|default(0) == 200
retries: 40
delay: 3
Hope this helps,
Jon
On Friday, September 8, 2017 at 1:29:40 PM UTC+1, Narahari 'n' Savitha
wrote:
>
> Friends:
>
> Thank you in advance for your time and attention.
>
> I am writing a playbook do the following on 6 tomcat servers.
>
> a. start tomcat
> b. wait for the app to come up on
> http://localhost:8080/tellMyVersion/version.jsp
> c. complete the play run after the above steps.
>
> I can start tomcat which is not a problem. I use the service module.
>
> I currently (without ansible) use the following script to test curl -sk -m
> 600 -w "\n" 'http://localhost:8080/tellMyVersion/version.jsp'
>
> It works fairly well since I am giving 10 min for curl to time out and
> that url I have put responds in about 7 or 8 mins. (worst case timings)
>
> The output of the curl command is something like (gives out the version of
> the app installed)
>
> 3.9.21
>
> With Ansible I want to be able to do this
>
> On batch tomcat the curl comes back in 4 mins
> On webtier tomcat the curl comes back in 6 mins
> On backend tomcat the curl takes the longest at 8 mins.
>
> I want to be able to loop thru each of them run the curl command get the
> output and if no response wait. If I get response I want to go to the next
> server and check that.
>
> I am not sure how to be in a loop going from one tomcat to another based
> on the output.
>
> Please help.
>
> -N
>
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/c08fc468-9341-4fbc-ac61-bfd933e94388%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.