You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

19 lines
795 B

  1. ---
  2. - name: Check which kube-control nodes are already members of the cluster
  3. command: "{{ bin_dir }}/kubectl get nodes --selector=node-role.kubernetes.io/control-plane -o json"
  4. register: kube_control_planes_raw
  5. ignore_errors: yes
  6. changed_when: false
  7. - name: Set fact joined_control_planes
  8. set_fact:
  9. joined_control_planes: "{{ ((kube_control_planes_raw.stdout | from_json)['items']) | default([]) | map(attribute='metadata') | map(attribute='name') | list }}"
  10. delegate_to: "{{ item }}"
  11. loop: "{{ groups['kube_control_plane'] }}"
  12. when: kube_control_planes_raw is succeeded
  13. run_once: yes
  14. - name: Set fact first_kube_control_plane
  15. set_fact:
  16. first_kube_control_plane: "{{ joined_control_planes | default([]) | first | default(groups['kube_control_plane'] | first) }}"