To check APIGEE component and restart if anything is down using ansible

I am trying to configure ansible in multinode apigee server to check the component status.
I am able to write the health check script and playbook to restart the component.
But I want to check the status first and then restart if required.

Any help or advice is appreciated.

Playbook script:

---

- hosts:

- 10.113.42.3

tasks:

- name: Run healthCheck.sh and output "ls /"

script: healthCheck.sh

become: yes

become_method: dzdo

become_user: root

register: out

- debug: var=out.stdout_lines

==================================================

=================================================

health check script:

/opt/apigee/apigee-service/bin/apigee-all status >/home/qa_srf_apigee_admin/monitor.tmp

===========================================

=========================================

1 0 201
0 REPLIES 0