refactor: split control plane role into init/join/copy tasks

This commit is contained in:
2026-06-30 23:39:34 +01:00
parent 90686995d6
commit 068659e174
10 changed files with 54 additions and 111 deletions
@@ -0,0 +1,20 @@
- name: Generate join command
ansible.builtin.command: kubeadm token create --print-join-command --kubeconfig /etc/kubernetes/admin.conf
register: kubernetes_control_plane_join_command
run_once: true
changed_when: false
- name: Get certificate key
ansible.builtin.command: kubeadm init phase upload-certs --upload-certs --kubeconfig /etc/kubernetes/admin.conf
register: kubernetes_control_plane_certificate_key
run_once: true
changed_when: false
- name: Join additional control planes
ansible.builtin.command: >-
{{ kubernetes_control_plane_join_command.stdout }}
--control-plane
--certificate-key
{{ kubernetes_control_plane_certificate_key.stdout_lines[-1] }}
args:
creates: /etc/kubernetes/admin.conf