From 9cffa671c8a17b12b1ba4c58a26e357611e673ea Mon Sep 17 00:00:00 2001 From: Sergey <6213510+sshnaidm@users.noreply.github.com> Date: Mon, 18 Aug 2025 23:15:41 +0300 Subject: [PATCH] Fix podman logout for newer Podman (#969) Fix #935 Signed-off-by: Sagi Shnaidman --- plugins/modules/podman_logout.py | 9 ++++++++- tests/integration/targets/podman_logout/tasks/main.yml | 1 - 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/plugins/modules/podman_logout.py b/plugins/modules/podman_logout.py index 21ef4ff..7fe9db5 100644 --- a/plugins/modules/podman_logout.py +++ b/plugins/modules/podman_logout.py @@ -91,6 +91,11 @@ from ansible.module_utils.basic import AnsibleModule def logout(module, executable, registry, authfile, all_registries, ignore_docker_credentials): command = [executable, "logout"] changed = False + # In check mode, do not execute the logout command. We cannot reliably + # determine current login state here without side effects, so report + # no change. + if module.check_mode: + return changed, "", "" if authfile: command.extend(["--authfile", authfile]) if registry: @@ -99,7 +104,9 @@ def logout(module, executable, registry, authfile, all_registries, ignore_docker command.append("--all") rc, out, err = module.run_command(command) if rc != 0: - if "Error: Not logged into" not in err: + # Treat "not logged into" as a no-op (idempotent) regardless of + # capitalization differences across podman versions. + if "not logged into" not in err.lower(): module.fail_json(msg="Unable to gather info for %s: %s" % (registry, err)) else: # If the command is successful, we managed to log out diff --git a/tests/integration/targets/podman_logout/tasks/main.yml b/tests/integration/targets/podman_logout/tasks/main.yml index e8632d5..ffb676a 100644 --- a/tests/integration/targets/podman_logout/tasks/main.yml +++ b/tests/integration/targets/podman_logout/tasks/main.yml @@ -23,7 +23,6 @@ containers.podman.podman_logout: executable: "{{ test_executable | default('podman') }}" register: non_existing_registry - ignore_errors: true - name: Check results assert: