From fab495f4dfc17b0814617fbc9224e8b9d128a1db Mon Sep 17 00:00:00 2001 From: Eri Bastos Date: Sat, 18 Feb 2023 15:06:22 -0400 Subject: [PATCH] Avoids removing / --- lib/ansible/modules/file.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/ansible/modules/file.py b/lib/ansible/modules/file.py index 72b510c3caa..327a7ae5c5c 100644 --- a/lib/ansible/modules/file.py +++ b/lib/ansible/modules/file.py @@ -517,6 +517,9 @@ def execute_diff_peek(path): def ensure_absent(path): + if path == '/': + raise AnsibleModuleError(results={'msg': "Refusing to delete /"}) + b_path = to_bytes(path, errors='surrogate_or_strict') prev_state = get_state(b_path) result = {}