refactor: split control plane role into init/join/copy tasks
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
- name: Check if cluster is initialised
|
||||
ansible.builtin.stat:
|
||||
path: /etc/kubernetes/admin.conf
|
||||
register: kubernetes_control_plane_admin_conf
|
||||
run_once: true
|
||||
|
||||
- name: Initialise Kubernetes cluster
|
||||
when: not kubernetes_control_plane_admin_conf.stat.exists
|
||||
block:
|
||||
- name: Copy kubeadm config
|
||||
ansible.builtin.template:
|
||||
src: kubeadm-config.yaml.j2
|
||||
dest: /tmp/kubeadm-config.yaml
|
||||
mode: "0600"
|
||||
run_once: true
|
||||
|
||||
- name: Initialise Kubernetes with kubeadm
|
||||
ansible.builtin.command: kubeadm init --config /tmp/kubeadm-config.yaml
|
||||
args:
|
||||
creates: /etc/kubernetes/admin.conf
|
||||
run_once: true
|
||||
Reference in New Issue
Block a user