7516fe142f
* Ansible: move to Ansible 3.4.0 which uses ansible-base 2.10.10 * Docs: add a note about ansible upgrade post 2.9.x * CI: ensure ansible is removed before ansible 3.x is installed to avoid pip failures * Ansible: use newer ansible-lint * Fix ansible-lint 5.0.11 found issues * syntax issues * risky-file-permissions * var-naming * role-name * molecule tests * Mitogen: use 0.3.0rc1 which adds support for ansible 2.10+ * Pin ansible-base to 2.10.11 to get package fix on RHEL8
64 lines
2.4 KiB
YAML
64 lines
2.4 KiB
YAML
---
|
|
- name: Lookup node IP in kubernetes
|
|
shell: >-
|
|
{{ bin_dir }}/kubectl get nodes {{ node }}
|
|
-o jsonpath='{range.status.addresses[?(@.type=="InternalIP")]}{.address}{"\n"}{end}'
|
|
register: remove_node_ip
|
|
when:
|
|
- inventory_hostname in groups['etcd']
|
|
- ip is not defined
|
|
- access_ip is not defined
|
|
delegate_to: "{{ groups['etcd']|first }}"
|
|
failed_when: false
|
|
|
|
- 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: Make sure node_ip is set
|
|
assert:
|
|
that: node_ip is defined and node_ip | length > 0
|
|
msg: "Etcd node ip is not set !"
|
|
when:
|
|
- inventory_hostname in groups['etcd']
|
|
|
|
- name: Lookup etcd member id
|
|
shell: "{{ bin_dir }}/etcdctl member list | grep {{ node_ip }} | cut -d, -f1"
|
|
register: etcd_member_id
|
|
ignore_errors: true # noqa ignore-errors
|
|
changed_when: false
|
|
check_mode: no
|
|
tags:
|
|
- facts
|
|
environment:
|
|
ETCDCTL_API: 3
|
|
ETCDCTL_CERT: "{{ etcd_cert_dir }}/admin-{{ groups['etcd']|first }}.pem"
|
|
ETCDCTL_KEY: "{{ etcd_cert_dir }}/admin-{{ groups['etcd']|first }}-key.pem"
|
|
ETCDCTL_CACERT: "{{ etcd_cert_dir }}/ca.pem"
|
|
ETCDCTL_ENDPOINTS: "https://{{ hostvars[groups['etcd']|first]['etcd_access_address'] |
|
|
default(hostvars[groups['etcd']|first]['ip']) |
|
|
default(hostvars[groups['etcd']|first]['fallback_ips'][groups['etcd']|first]) }}:2379"
|
|
delegate_to: "{{ groups['etcd']|first }}"
|
|
when: inventory_hostname in groups['etcd']
|
|
|
|
- name: Remove etcd member from cluster
|
|
command: "{{ bin_dir }}/etcdctl member remove {{ etcd_member_id.stdout }}"
|
|
register: etcd_member_in_cluster
|
|
changed_when: false
|
|
check_mode: no
|
|
tags:
|
|
- facts
|
|
environment:
|
|
ETCDCTL_API: 3
|
|
ETCDCTL_CERT: "{{ etcd_cert_dir }}/admin-{{ groups['etcd']|first }}.pem"
|
|
ETCDCTL_KEY: "{{ etcd_cert_dir }}/admin-{{ groups['etcd']|first }}-key.pem"
|
|
ETCDCTL_CACERT: "{{ etcd_cert_dir }}/ca.pem"
|
|
ETCDCTL_ENDPOINTS: "https://{{ hostvars[groups['etcd']|first]['etcd_access_address'] |
|
|
default(hostvars[groups['etcd']|first]['ip']) |
|
|
default(hostvars[groups['etcd']|first]['fallback_ips'][groups['etcd']|first]) }}:2379"
|
|
delegate_to: "{{ groups['etcd']|first }}"
|
|
when:
|
|
- inventory_hostname in groups['etcd']
|
|
- etcd_member_id.stdout | length > 0
|