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

Fix podman logout for newer Podman (#969)

Fix #935

Signed-off-by: Sagi Shnaidman <sshnaidm@redhat.com>
This commit is contained in:
Sergey 2025-08-18 23:15:41 +03:00 committed by GitHub
parent f4b57ac265
commit 9cffa671c8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 2 deletions

View file

@ -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

View file

@ -23,7 +23,6 @@
containers.podman.podman_logout:
executable: "{{ test_executable | default('podman') }}"
register: non_existing_registry
ignore_errors: true
- name: Check results
assert: