summaryrefslogtreecommitdiffstats
path: root/roles/etcd/tasks/auxiliary/force_new_cluster.yml
blob: ae8a36130df0882f06505f8640521a5bbfb20209 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
---
- name: Set ETCD_FORCE_NEW_CLUSTER=true on first etcd host
  lineinfile:
    line: "ETCD_FORCE_NEW_CLUSTER=true"
    dest: /etc/etcd/etcd.conf
    backup: true

- name: Start etcd
  systemd:
    name: "{{ etcd_service }}"
    state: started

- name: Wait for cluster to become healthy after bringing up first member
  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: l_etcd_migrate_health
  until: l_etcd_migrate_health.rc == 0
  retries: 3
  delay: 30

- name: Unset ETCD_FORCE_NEW_CLUSTER=true on first etcd host
  lineinfile:
    line: "ETCD_FORCE_NEW_CLUSTER=true"
    dest: /etc/etcd/etcd.conf
    state: absent
    backup: true

- name: Restart first etcd host
  systemd:
    name: "{{ etcd_service }}"
    state: restarted