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

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

You’re probably after the “Do until” example found in the docs: http://docs.ansible.com/ansible/playbooks_loops.html