Skip to content

Instantly share code, notes, and snippets.

@ei-grad
Last active May 7, 2017 12:13
Show Gist options
  • Save ei-grad/5f6730170dffa8eaca1447f7d74f2d8d to your computer and use it in GitHub Desktop.
Save ei-grad/5f6730170dffa8eaca1447f7d74f2d8d to your computer and use it in GitHub Desktop.
Ansible playbook for rolling elasticsearch cluster upgrade
- name: upgrade elasticsearch
hosts: elastic
serial: 1
tasks:
- name: stop elasticsearch
service: name=elasticsearch state=stopped
- name: remove elasticsearch plugins
command: /usr/share/elasticsearch/bin/elasticsearch-plugin remove x-pack
- name: upgrade elasticsearch
apt: name=elasticsearch state=latest
- name: install elasticsearch plugins
command: /usr/share/elasticsearch/bin/elasticsearch-plugin install -b x-pack
- name: restart elasticsearch
service: name=elasticsearch state=restarted
- name: wait for green cluster state
shell: "while curl -s {{elasticsearch_url}}/_cat/health | grep -v green; do sleep 1; done"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment