Reputation: 167
It may be a weird question and I have tried searching but couldn't find what I am looking for. I have a below playbook which starts tomcat and checks the status. How do i put a condition to wait for it to become online before my playbook finishes. I have looked into wait_for module but not able to put up in the playbook.
---
- name: Starting tomcat service on remote host
shell: "svcadm enable tomcat"
ignore_errors: true
- pause:
seconds: 10
- name: Check the State of tomcat service on the remote host
shell: "svcs tomcat"
register: tomcat_status
- set_fact:
tomcat_state: "{{ tomcat_status.stdout_lines.1.split().0 }}"
The value of tomcat_state should be "online" which tells us that tomcat is up.
Is there anything we can do here OR may be some other way? Appreciate if someone can give some inputs
Upvotes: 0
Views: 878
Reputation: 510
- name: wait for completion
wait_for:
port: <your_port>
delay: 60
timeout: 500
In this way, this task wait for 60 secs, then check if something is up on the port you specified, and it tries for 500s
Upvotes: 1