# Recurring tasks

**URL:** <https://forum.ansible.com/t/recurring-tasks/18623>\
**Category:** Ansible Project\
**Created:** [June 26, 2015, 6:31pm UTC](https://forum.ansible.com/t/recurring-tasks/18623 "2015-06-26T18:31:56Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Darvin\_Denmian](https://avatars.discourse-cdn.com/v4/letter/d/c68b51/32.png) [@Darvin\_Denmian](https://forum.ansible.com/u/Darvin_Denmian)\
**Post date:** [June 26, 2015, 6:31pm UTC](https://forum.ansible.com/t/recurring-tasks/18623/1 "2015-06-26T18:31:56Z")

</div>

Hi !

I need a suggestion from you to solve a problem I’m facing, here it is…

The problem:  
I have a ElasticSearch cluster composed of 6 nodes. During the non work hours I would like to substitute 4 of those 6 ec2 instance for a different server (cheaper instance). The main problem is: How can I proceed to the next server , and remove it from the cluster, since I must wait for the cluster to get in the “green state” ?

Below you can see how I stop the instances:

- name: Stopping ES  
ec2:  
instance\_ids: “{{ item }}”  
region: sa-east-1  
state: stopped  
wait: True  
with\_items: es\_ids  
tags:
- esi\_stop

and how I run the cluster health check:

- name: Checking ES Cluster Status  
uri:  
url=http://\<cluster\_address\>:9200/\_cluster/health?pretty  
method=GET  
status\_code=200  
register: cluster\_status  
until: “‘{{ cluster\_status.json.status }}’ == ‘green’”  
retries: 5  
delay: 30  
tags:
- check\_cluster\_status

Thanks in advance!
