mirror of
https://github.com/kubernetes-sigs/kubespray.git
synced 2026-02-28 09:39:12 +03:00
Currently, if changing the inventory variable `kubeadm_patches`, new patches will be created, but the existing ones will also be left on the filesystem, and applied by kubeadm ; this means that removed or changed configuration can linger. Cleanup old patches (which are the difference between existing patches on filesystem and the one created for the current runs). Co-authored-by: Max Gautier <mg@max.gautier.name>
38 lines
1.1 KiB
YAML
38 lines
1.1 KiB
YAML
---
|
|
- name: Kubeadm | Create directory to store kubeadm patches
|
|
file:
|
|
path: "{{ kubeadm_patches_dir }}"
|
|
state: directory
|
|
mode: "0750"
|
|
when: kubeadm_patches | length > 0
|
|
|
|
- name: Kubeadm | List existing kubeadm patches
|
|
find:
|
|
paths:
|
|
- "{{ kubeadm_patches_dir }}"
|
|
file_type: file
|
|
use_regex: true
|
|
patterns:
|
|
- '^(kube-apiserver|kube-controller-manager|kube-scheduler|etcd|kubeletconfiguration)[0-9]+\+(strategic|json|merge).yaml$'
|
|
register: existing_kubeadm_patches
|
|
|
|
- name: Kubeadm | Copy kubeadm patches from inventory files
|
|
copy:
|
|
content: "{{ item.patch | to_yaml }}"
|
|
dest: "{{ kubeadm_patches_dir }}/{{ item.target }}{{ suffix }}+{{ item.type | d('strategic') }}.yaml"
|
|
owner: "root"
|
|
mode: "0644"
|
|
loop: "{{ kubeadm_patches }}"
|
|
loop_control:
|
|
index_var: suffix
|
|
register: current_kubeadm_patches
|
|
|
|
- name: Kubeadm | Delete old patches
|
|
loop: "{{ existing_kubeadm_patches.files | map(attribute='path') |
|
|
difference(
|
|
current_kubeadm_patches.results | map(attribute='dest')
|
|
) }}"
|
|
file:
|
|
state: absent
|
|
path: "{{ item }}"
|