From 37a4b28b6459c98073ccde1758fc2a95edc215c9 Mon Sep 17 00:00:00 2001 From: emiran-orange Date: Tue, 20 Dec 2022 09:27:06 +0100 Subject: [PATCH] Find files before changing attributes --- roles/reset/tasks/main.yml | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/roles/reset/tasks/main.yml b/roles/reset/tasks/main.yml index 1ae226380..24be4cda8 100644 --- a/roles/reset/tasks/main.yml +++ b/roles/reset/tasks/main.yml @@ -253,12 +253,24 @@ - enable_nodelocaldns|default(false)|bool - nodelocaldns_device.stat.exists -- name: reset | Remove immutable flag from /var/lib/kubelet subdirs +- name: reset | find files/dirs with immutable flag in /var/lib/kubelet + command: lsattr -laR /var/lib/kubelet + become: true + register: var_lib_kubelet_files_dirs_w_attrs + changed_when: false + no_log: true + +- name: reset | remove immutable flag from files/dirs in /var/lib/kubelet file: - path: /var/lib/kubelet - state: directory + path: "{{ filedir_path }}" + state: touch attributes: "-i" - recurse: true + loop: "{{ var_lib_kubelet_files_dirs_w_attrs.stdout_lines|select('search', 'Immutable')|list }}" + loop_control: + loop_var: file_dir_line + label: "{{ filedir_path }}" + vars: + filedir_path: "{{ file_dir_line.split(' ')[0] }}" - name: reset | delete some files and directories file: