Created
February 15, 2016 02:20
-
-
Save abn/526781365832b1ab9785 to your computer and use it in GitHub Desktop.
Mantl: Reset consul peers to recover from a cluster outage.
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
--- | |
# https://www.consul.io/docs/guides/outage.html | |
# do a rolling restart; be nice to the cluster | |
- hosts: role=control | |
serial: 1 | |
gather_facts: no | |
tasks: | |
- name: set consul maintenance enable | |
command: consul maint -enable -reason "{{ lookup('env', 'USER') }} reset consul peers" | |
tags: | |
- reset | |
- name: stop consul | |
become: yes | |
service: > | |
name=consul | |
state=stopped | |
tags: | |
- reset | |
- copy: | |
dest: /var/lib/consul/raft/peers.json | |
content: "[{% for host in groups[consul_servers_group] | intersect(groups[consul_dc_group]) %}\"{{ hostvars[host].private_ipv4 }}:8300\"{% if not loop.last %}, {% endif %}{% endfor %}]" | |
tags: | |
- configure | |
- name: start consul | |
become: yes | |
service: > | |
name=consul | |
state=started | |
tags: | |
- reset | |
- name: wait for consul to listen | |
wait_for: | |
port: 8500 | |
tags: | |
- restart | |
- name: set consul maintenance disable | |
command: consul maint -disable | |
tags: | |
- restart |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Would you mind making a PR for this? Then we could close mantl/mantl#948