1
0
Fork 0
mirror of https://github.com/containers/ansible-podman-collections.git synced 2026-02-04 07:11:49 +00:00

Add protection for systemd files deletion (#509)

Signed-off-by: Sagi Shnaidman <sshnaidm@redhat.com>

Signed-off-by: Sagi Shnaidman <sshnaidm@redhat.com>
This commit is contained in:
Sergey 2022-11-10 14:06:55 -05:00 committed by GitHub
parent 5198b726fb
commit 5c68ee09fe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -143,7 +143,9 @@ def delete_systemd(module, module_params, name, version):
data = json.loads(systemd)
for file_name in data.keys():
file_name += ".service"
os.unlink(os.path.join(sysconf['path'], file_name))
file_path = os.path.join(sysconf['path'], file_name)
if os.path.exists(file_path):
os.unlink(file_path)
return
except Exception as e:
module.log(