refactor: split control plane role into init/join/copy tasks
This commit is contained in:
@@ -1,63 +1,11 @@
|
||||
- name: Install kube-vip static pod
|
||||
- name: Configure kube-vip static pod manifest
|
||||
ansible.builtin.import_tasks: kube-vip.yaml
|
||||
|
||||
- name: Copy kubeadm config
|
||||
ansible.builtin.template:
|
||||
src: kubeadm-config.yaml.j2
|
||||
dest: /tmp/kubeadm-config.yaml
|
||||
mode: "0600"
|
||||
|
||||
- name: Initialise Kubernetes cluster
|
||||
ansible.builtin.command: kubeadm init --config /tmp/kubeadm-config.yaml
|
||||
args:
|
||||
creates: /etc/kubernetes/admin.conf
|
||||
run_once: true
|
||||
ansible.builtin.include_tasks: init-cluster.yaml
|
||||
|
||||
- name: Join nodes as control planes
|
||||
ansible.builtin.include_tasks: join-cluster.yaml
|
||||
|
||||
- name: Copy Kubernetes Admin Configuration
|
||||
- name: Copy Kubernetes admin configuration on all nodes
|
||||
ansible.builtin.include_tasks: copy-config.yaml
|
||||
run_once: true
|
||||
|
||||
|
||||
- name: Generate Join Command
|
||||
ansible.builtin.command: kubeadm token create --print-join-command
|
||||
register: kubernetes_control_plane_join_command
|
||||
run_once: true
|
||||
changed_when: true
|
||||
|
||||
|
||||
- name: Get Certificate Key
|
||||
ansible.builtin.shell: set -o pipefail && kubeadm init phase upload-certs --upload-certs | tail -n 1
|
||||
register: kubernetes_control_plane_certificate_key
|
||||
run_once: true
|
||||
changed_when: true
|
||||
|
||||
|
||||
- name: Join Additional Control Planes
|
||||
ansible.builtin.command: >-
|
||||
{{ kubernetes_control_plane_join_command.stdout }}
|
||||
--control-plane
|
||||
--certificate-key
|
||||
{{ kubernetes_control_plane_certificate_key.stdout }}
|
||||
args:
|
||||
creates: /etc/kubernetes/admin.conf
|
||||
|
||||
|
||||
- name: Copy Kubernetes Admin Configuration
|
||||
ansible.builtin.include_tasks: copy-config.yaml
|
||||
|
||||
|
||||
- name: Untaint control planes
|
||||
ansible.builtin.import_tasks: untaint.yaml
|
||||
|
||||
|
||||
- name: Install Tools
|
||||
ansible.builtin.import_tasks: tools.yaml
|
||||
|
||||
|
||||
- name: Install Cilium CNI
|
||||
ansible.builtin.import_tasks: cilium.yaml
|
||||
|
||||
|
||||
# - name: Install Longhorn CSI
|
||||
# ansible.builtin.import_tasks: longhorn.yaml
|
||||
|
||||
Reference in New Issue
Block a user