# Is there a way in Ansible to check a particular condition (e.g., the health status of Elasticsearch cluster) in a loop?

**URL:** <https://forum.ansible.com/t/is-there-a-way-in-ansible-to-check-a-particular-condition-e-g-the-health-status-of-elasticsearch-cluster-in-a-loop/23343>\
**Category:** Ansible Project\
**Created:** [December 29, 2016, 6:16am UTC](https://forum.ansible.com/t/is-there-a-way-in-ansible-to-check-a-particular-condition-e-g-the-health-status-of-elasticsearch-cluster-in-a-loop/23343 "2016-12-29T06:16:33Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Qian\_Zhang](https://avatars.discourse-cdn.com/v4/letter/q/779978/32.png) [@Qian\_Zhang](https://forum.ansible.com/u/Qian_Zhang)\
**Post date:** [December 29, 2016, 6:16am UTC](https://forum.ansible.com/t/is-there-a-way-in-ansible-to-check-a-particular-condition-e-g-the-health-status-of-elasticsearch-cluster-in-a-loop/23343/1 "2016-12-29T06:16:33Z")

</div>

Hi,

I am going to use Ansible to deploy Elasticsearch and Logstash. Before deploying Logstash, I’d like to check if the health status of Elasticsearch cluster is green or not, e.g.,

$ curl -s 127.0.0.1:9200/\_cat/health?v  
epoch timestamp cluster status  
1482992016 06:13:36 elasticsearch-default green

It will take some time for Elasticsearch cluster to become healthy, so I’d like to check it in a loop until it become healthy or timeout. Is it possible to do this with Ansible? Thanks!

Regards,  
Qian

---

<div class="post-metadata">

**Author:** ![Trond\_Hindenes](https://avatars.discourse-cdn.com/v4/letter/t/96bed5/32.png) [@Trond\_Hindenes](https://forum.ansible.com/u/Trond_Hindenes)\
**Post date:** [January 2, 2017, 1:27pm UTC](https://forum.ansible.com/t/is-there-a-way-in-ansible-to-check-a-particular-condition-e-g-the-health-status-of-elasticsearch-cluster-in-a-loop/23343/2 "2017-01-02T13:27:26Z")

</div>

You’re probably after the “Do until” example found in the docs: [http://docs.ansible.com/ansible/playbooks\_loops.html](http://docs.ansible.com/ansible/playbooks_loops.html)
