From ed681ef10efc95dfbc9eb6c9d54eab98ad9ac165 Mon Sep 17 00:00:00 2001 From: Sergey Date: Mon, 2 Aug 2021 12:59:43 +0300 Subject: [PATCH] Fix idempotency with systemd podman files (#278) Fix #276 Label 'podman_systemd_unit' is the marker for container starting from systemd generated file. In this case: * Ignore podman_systemd_unit label * Ignore cidfile settings when this label presents --- plugins/module_utils/podman/podman_container_lib.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/plugins/module_utils/podman/podman_container_lib.py b/plugins/module_utils/podman/podman_container_lib.py index d3f7cf6..d4a2763 100644 --- a/plugins/module_utils/podman/podman_container_lib.py +++ b/plugins/module_utils/podman/podman_container_lib.py @@ -759,6 +759,11 @@ class PodmanContainerDiff: def diffparam_cidfile(self): before = self.info['hostconfig']['containeridfile'] after = self.params['cidfile'] + labels = self.info['config']['labels'] or {} + # Ignore cidfile that is coming from systemd files + # https://github.com/containers/ansible-podman-collections/issues/276 + if 'podman_systemd_unit' in labels: + after = before return self._diff_update_and_compare('cidfile', before, after) def diffparam_command(self): @@ -924,6 +929,11 @@ class PodmanContainerDiff: str(k).lower(): str(v) for k, v in self.params['label'].items() }) + # Strip out labels that are coming from systemd files + # https://github.com/containers/ansible-podman-collections/issues/276 + if 'podman_systemd_unit' in before: + after.pop('podman_systemd_unit', None) + before.pop('podman_systemd_unit', None) return self._diff_update_and_compare('label', before, after) def diffparam_log_driver(self):