-
-
Save jigante/d9d89c2480626d6c5aca to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- name: Rolling elasticsearch cluster restart | |
hosts: es | |
serial: 1 | |
sudo: yes | |
vars: | |
uribody_true: '{"transient":{"cluster.routing.allocation.enable":"none"}}' | |
uribody_false: '{"transient":{"cluster.routing.allocation.enable":"all"}}' | |
es_http_port: 9200 | |
es_transport_port: 9300 | |
pre_tasks: | |
- name: Disable shard allocation for the cluster | |
uri: url=http://localhost:{{ es_http_port }}/_cluster/settings method=PUT body='{{ uribody_true }}' | |
tasks: | |
- name: Restart elasticsearch node | |
service: name=elasticsearch state=restarted | |
- name: Wait for elasticsearch to come back up | |
wait_for: port={{ es_transport_port }} delay=35 | |
post_tasks: | |
- name: Enable shard allocation for the cluster | |
uri: url=http://localhost:{{ es_http_port }}/_cluster/settings method=PUT body='{{ uribody_false }}' | |
delay: 3 | |
tags: [ "elasticsearch" , "esconfig" ] | |
- name: Wait for cluster health to return to yellow | |
uri: url=http://localhost:{{ es_http_port }}/_cluster/health method=GET | |
register: response | |
until: "response.json.status == 'yellow'" | |
retries: 5 | |
delay: 30 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- name: Elasticsearch rolling upgrade | |
hosts: es | |
serial: 1 | |
sudo: yes | |
vars: | |
uribody_true: '{"transient":{"cluster.routing.allocation.enable":"none"}}' | |
uribody_false: '{"transient":{"cluster.routing.allocation.enable":"all"}}' | |
es_http_port: 9200 | |
es_transport_port: 9300 | |
pre_tasks: | |
- name: Disable shard allocation for the cluster | |
uri: url=http://localhost:{{ es_http_port }}/_cluster/settings method=PUT body='{{ uribody_true }}' | |
tasks: | |
- name: Shutdown elasticsearch node | |
uri: url=http://localhost:{{ es_http_port }}/_cluster/nodes/_local/_shutdown method=POST | |
- name: Wait for all shards to be reallocated | |
uri: url=http://localhost:{{ es_http_port }}/_cluster/health method=GET | |
register: response | |
until: "response.json.relocating_shards == 0" | |
retries: 5 | |
delay: 30 | |
- name: Update elasticsearch | |
yum: name=elasticsearch state=latest | |
- name: Start elasticsearch | |
service: name=elasticsearch enabled=yes state=started | |
- name: Wait for elasticsearch node to come back up | |
wait_for: port={{ es_transport_port }} delay=35 | |
- name: Wait for cluster health to return to yellow | |
uri: url=http://localhost:{{ es_http_port }}/_cluster/health method=GET | |
register: response | |
until: "response.json.status == 'yellow'" | |
retries: 5 | |
delay: 30 | |
post_tasks: | |
- name: Enable shard allocation for the cluster | |
uri: url=http://localhost:{{ es_http_port }}/_cluster/settings method=PUT body='{{ uribody_false }}' | |
delay: 3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment