summaryrefslogtreecommitdiffstats
path: root/roles/etcd_migrate/tasks/check_cluster_health.yml
blob: 201d83f990ed6ef7837c5ffad841e120c1d71a3a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
---
- name: Check cluster health
  command: >
    etcdctl --cert-file {{ etcd_peer_cert_file }} --key-file {{ etcd_peer_key_file }} --ca-file {{ etcd_peer_ca_file }} --endpoint https://{{ etcd_peer }}:{{ etcd_client_port }} cluster-health
  register: etcd_cluster_health
  changed_when: false
  failed_when: false

- name: Assume a member is not healthy
  set_fact:
    etcd_member_healthy: false

- name: Get member item health status
  set_fact:
    etcd_member_healthy: true
  with_items: "{{ etcd_cluster_health.stdout_lines }}"
  when: "(etcd_peer in item) and ('is healthy' in item)"

- name: Check the etcd cluster health
  # TODO(jchaloup): should we fail or ask user if he wants to continue? Or just wait until the cluster is healthy?
  fail:
    msg: "Etcd member {{ etcd_peer }} is not healthy"
  when: not etcd_member_healthy