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

podman_systemd: Ignore header when comparing systemd files content (#558)

Fix #557
Signed-off-by: Sagi Shnaidman <sshnaidm@redhat.com>
This commit is contained in:
Sergey 2023-03-04 18:06:23 +02:00 committed by GitHub
parent 7c06ddec3b
commit dba0d78844
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -456,7 +456,14 @@ def generate_systemd(module):
current_unit_file_content = unit_file.read()
# If current unit file content is the same as the
# generated content
if current_unit_file_content == unit_content:
# Remove comments from files, before comparing
current_unit_file_content_nocmnt = "\n".join([
line for line in current_unit_file_content.splitlines()
if not line.startswith('#')])
unit_content_nocmnt = "\n".join([
line for line in unit_content.splitlines()
if not line.startswith('#')])
if current_unit_file_content_nocmnt == unit_content_nocmnt:
# We don't need to write it
need_to_write_file = False