2021-12-06 16:16:32 +08:00
|
|
|
---
|
|
|
|
|
|
|
|
- name: Check which kube-control nodes are already members of the cluster
|
|
|
|
command: "{{ bin_dir }}/kubectl get nodes --selector=node-role.kubernetes.io/control-plane -o json"
|
|
|
|
register: kube_control_planes_raw
|
|
|
|
ignore_errors: yes
|
|
|
|
changed_when: false
|
|
|
|
|
2024-01-24 14:38:35 +08:00
|
|
|
- name: Set fact joined_control_planes
|
2021-12-06 16:16:32 +08:00
|
|
|
set_fact:
|
2023-07-05 11:36:54 +08:00
|
|
|
joined_control_planes: "{{ ((kube_control_planes_raw.stdout | from_json)['items']) | default([]) | map(attribute='metadata') | map(attribute='name') | list }}"
|
2021-12-06 16:16:32 +08:00
|
|
|
delegate_to: item
|
|
|
|
loop: "{{ groups['kube_control_plane'] }}"
|
|
|
|
when: kube_control_planes_raw is succeeded
|
|
|
|
run_once: yes
|
|
|
|
|
|
|
|
- name: Set fact first_kube_control_plane
|
|
|
|
set_fact:
|
2023-07-05 11:36:54 +08:00
|
|
|
first_kube_control_plane: "{{ joined_control_planes | default([]) | first | default(groups['kube_control_plane'] | first) }}"
|