2020-06-09 12:37:17 +00:00
|
|
|
---
|
|
|
|
- name: Set node IP
|
|
|
|
set_fact:
|
|
|
|
node_ip: "{{ ip | default(access_ip | default(remove_node_ip.stdout)) | trim }}"
|
|
|
|
when:
|
|
|
|
- inventory_hostname in groups['etcd']
|
|
|
|
|
|
|
|
- name: Lookup etcd member id
|
2020-07-01 11:56:16 +00:00
|
|
|
shell: "{{ bin_dir }}/etcdctl --no-sync member list | grep {{ node_ip }} | cut -d: -f1"
|
2020-06-09 12:37:17 +00:00
|
|
|
register: etcd_member_id
|
|
|
|
ignore_errors: true
|
|
|
|
changed_when: false
|
|
|
|
check_mode: no
|
|
|
|
tags:
|
|
|
|
- facts
|
|
|
|
environment:
|
2020-07-01 11:56:16 +00:00
|
|
|
ETCDCTL_API: 2
|
|
|
|
ETCDCTL_ENDPOINTS: "{{ etcd_access_addresses }}"
|
2020-06-09 12:37:17 +00:00
|
|
|
ETCDCTL_CERT_FILE: "{{ etcd_cert_dir }}/admin-{{ groups['etcd']|first }}.pem"
|
|
|
|
ETCDCTL_KEY_FILE: "{{ etcd_cert_dir }}/admin-{{ groups['etcd']|first }}-key.pem"
|
|
|
|
ETCDCTL_CA_FILE: "{{ etcd_cert_dir }}/ca.pem"
|
|
|
|
delegate_to: "{{ groups['etcd']|first }}"
|
|
|
|
when:
|
|
|
|
- inventory_hostname in groups['etcd']
|
|
|
|
|
|
|
|
- name: Remove etcd member from cluster
|
2020-07-01 11:56:16 +00:00
|
|
|
shell: "{{ bin_dir }}/etcdctl --no-sync member remove {{ etcd_member_id.stdout }}"
|
2020-06-09 12:37:17 +00:00
|
|
|
register: etcd_member_in_cluster
|
|
|
|
ignore_errors: false
|
|
|
|
retries: 6
|
|
|
|
delay: 5
|
|
|
|
until: etcd_member_in_cluster.rc == 0
|
|
|
|
changed_when: false
|
|
|
|
check_mode: no
|
|
|
|
tags:
|
|
|
|
- facts
|
|
|
|
environment:
|
2020-07-01 11:56:16 +00:00
|
|
|
ETCDCTL_API: 2
|
|
|
|
ETCDCTL_ENDPOINTS: "{{ etcd_access_addresses }}"
|
2020-06-09 12:37:17 +00:00
|
|
|
ETCDCTL_CERT_FILE: "{{ etcd_cert_dir }}/admin-{{ groups['etcd']|first }}.pem"
|
|
|
|
ETCDCTL_KEY_FILE: "{{ etcd_cert_dir }}/admin-{{ groups['etcd']|first }}-key.pem"
|
|
|
|
ETCDCTL_CA_FILE: "{{ etcd_cert_dir }}/ca.pem"
|
|
|
|
delegate_to: "{{ groups['etcd']|first }}"
|
|
|
|
when:
|
|
|
|
- inventory_hostname in groups['etcd']
|
|
|
|
- etcd_member_id.stdout | length > 0
|