diff --git a/roles/kubernetes/control-plane/meta/main.yml b/roles/kubernetes/control-plane/meta/main.yml index 7d793f92f..7b2cfe365 100644 --- a/roles/kubernetes/control-plane/meta/main.yml +++ b/roles/kubernetes/control-plane/meta/main.yml @@ -1,5 +1,6 @@ --- dependencies: + - role: kubernetes/kubeadm_common - role: kubernetes/tokens when: kube_token_auth tags: diff --git a/roles/kubernetes/control-plane/tasks/kubeadm-setup.yml b/roles/kubernetes/control-plane/tasks/kubeadm-setup.yml index c13b6e833..d7783036b 100644 --- a/roles/kubernetes/control-plane/tasks/kubeadm-setup.yml +++ b/roles/kubernetes/control-plane/tasks/kubeadm-setup.yml @@ -176,21 +176,6 @@ - apiserver_sans_ip_check.changed or apiserver_sans_host_check.changed - not kube_external_ca_mode -- name: Kubeadm | Create directory to store kubeadm patches - file: - path: "{{ kubeadm_patches.dest_dir }}" - state: directory - mode: "0640" - when: kubeadm_patches is defined and kubeadm_patches.enabled - -- name: Kubeadm | Copy kubeadm patches from inventory files - copy: - src: "{{ kubeadm_patches.source_dir }}/" - dest: "{{ kubeadm_patches.dest_dir }}" - owner: "root" - mode: "0644" - when: kubeadm_patches is defined and kubeadm_patches.enabled - - name: Kubeadm | Initialize first control plane node command: >- timeout -k {{ kubeadm_init_timeout }} {{ kubeadm_init_timeout }} diff --git a/roles/kubernetes/kubeadm/meta/main.yml b/roles/kubernetes/kubeadm/meta/main.yml new file mode 100644 index 000000000..4e7278559 --- /dev/null +++ b/roles/kubernetes/kubeadm/meta/main.yml @@ -0,0 +1,3 @@ +--- +dependencies: + - role: kubernetes/kubeadm_common diff --git a/roles/kubernetes/kubeadm/tasks/main.yml b/roles/kubernetes/kubeadm/tasks/main.yml index 9e01f5fe5..cb29e2a6a 100644 --- a/roles/kubernetes/kubeadm/tasks/main.yml +++ b/roles/kubernetes/kubeadm/tasks/main.yml @@ -83,21 +83,6 @@ mode: "0640" when: ('kube_control_plane' not in group_names) -- name: Kubeadm | Create directory to store kubeadm patches - file: - path: "{{ kubeadm_patches.dest_dir }}" - state: directory - mode: "0640" - when: kubeadm_patches is defined and kubeadm_patches.enabled - -- name: Kubeadm | Copy kubeadm patches from inventory files - copy: - src: "{{ kubeadm_patches.source_dir }}/" - dest: "{{ kubeadm_patches.dest_dir }}" - owner: "root" - mode: "0644" - when: kubeadm_patches is defined and kubeadm_patches.enabled - - name: Join to cluster if needed environment: PATH: "{{ bin_dir }}:{{ ansible_env.PATH }}:/sbin" diff --git a/roles/kubernetes/kubeadm_common/tasks/main.yml b/roles/kubernetes/kubeadm_common/tasks/main.yml new file mode 100644 index 000000000..b1f316e22 --- /dev/null +++ b/roles/kubernetes/kubeadm_common/tasks/main.yml @@ -0,0 +1,15 @@ +--- +- name: Kubeadm | Create directory to store kubeadm patches + file: + path: "{{ kubeadm_patches.dest_dir }}" + state: directory + mode: "0640" + when: kubeadm_patches is defined and kubeadm_patches.enabled + +- name: Kubeadm | Copy kubeadm patches from inventory files + copy: + src: "{{ kubeadm_patches.source_dir }}/" + dest: "{{ kubeadm_patches.dest_dir }}" + owner: "root" + mode: "0644" + when: kubeadm_patches is defined and kubeadm_patches.enabled