
    Vh]                     V    d dl mZmZmZ eZdZdZd dlm	Z	 d Z
d Zedk(  r e        yy)	    )absolute_importdivisionprint_functiona
  
module: podman_logout
author:
  - "Clemens Lange (@clelange)"
short_description: Log out of a container registry using podman
notes: []
description:
  - Log out of a container registry server using the podman logout command
    by deleting the cached credentials stored in the `auth.json` file.
    If the registry is not specified, the first registry under
    `[registries.search]` from `registries.conf `will be used. The path of
    the authentication file can be overridden by the user by setting the
    `authfile` flag. The default path used is
    `${XDG_RUNTIME_DIR}/containers/auth.json`.
    All the cached credentials can be removed by setting the `all` flag.
    Warning - podman will use credentials in `${HOME}/.docker/config.json`
    to authenticate in case they are not found in the default `authfile`.
    However, the logout command will only removed credentials in the
    `authfile` specified.
requirements:
  - "Podman installed on host"
options:
  registry:
    description:
      - Registry server. If the registry is not specified,
        the first registry under `[registries.search]` from
        `registries.conf` will be used.
    type: str
  authfile:
    description:
      - Path of the authentication file. Default is
        ``${XDG_RUNTIME_DIR}/containers/auth.json``
        You can also override the default path of the authentication
        file by setting the ``REGISTRY_AUTH_FILE`` environment
        variable. ``export REGISTRY_AUTH_FILE=path``
    type: path
  all:
    description:
      - Remove the cached credentials for all registries in the auth file.
    type: bool
  ignore_docker_credentials:
    description:
      - Credentials created using other tools such as `docker login` are not
        removed unless the corresponding `authfile` is explicitly specified.
        Since podman also uses existing credentials in these files by default
        (for docker e.g. `${HOME}/.docker/config.json`), module execution will
        fail if a docker login exists for the registry specified in any
        `authfile` is used by podman. This can be ignored by setting
        `ignore_docker_credentials` to `true` - the credentials will be kept and
        `changed` will be false.
        This option cannot be used together with `all` since in this case
        podman will not check for existing `authfiles` created by other tools.
    type: bool
  executable:
    description:
      - Path to C(podman) executable if it is not in the C($PATH) on the
        machine running C(podman)
    default: 'podman'
    type: str
aI  
- name: Log out of default registry
  podman_logout:

- name: Log out of quay.io
  podman_logout:
    registry: quay.io

- name: Log out of all registries in auth file
  podman_logout:
    all: true

- name: Log out of all registries in specified auth file
  podman_logout:
    authfile: $HOME/.docker/config.json
    all: true
)AnsibleModulec                 J   |dg}d}|r|j                  d|g       |r|j                  |       |r|j                  d       | j                  |      \  }}	}
|dk7  rd|
vr| j                  d|d|
	       nd
}d|	v r!|s| j                  d|xs dd|		       nd}||	|
fS )NlogoutFz
--authfilez--allr   zError: Not logged intozUnable to gather info for z: )msgTz)Existing credentials were established viazUnable to log out  )extendappendrun_command	fail_json)module
executableregistryauthfileall_registriesignore_docker_credentialscommandchangedrcouterrs              s/home/dcms/DCMS/lib/python3.12/site-packages/ansible_collections/containers/podman/plugins/modules/podman_logout.pyr   r   Z   s    8$GGh/0x w%%g.LBS	Qw#3.xQT!UV
 2c9 )x~2~s!STGC    c                     t        t        t        dd      t        d      t        d      t        d      t        d            dd	d
gdd
gf      } | j                  d	   }| j                  d   }| j                  d
   }| j                  d   }| j                  | j                  d   d      }t	        | |||||      \  }}}|||d}	 | j
                  di |	 y )Nstrpodman)typedefault)r   pathbool)r   r   r   allr   Tr   r#   r   )argument_specsupports_check_modemutually_exclusiver   r   )required)r   stdoutstderr )r   dictparamsget_bin_pathr   	exit_json)
r   r   r   r   r   r   r   r   r   resultss
             r   mainr0   v   s    9u%v&&!&*&7
 !(%0
F }}Z(H}}Z(H]]5)N &.I J$$V]]<%@4$PJvz8X-/HJGS# G Fwr   __main__N)
__future__r   r   r   r   __metaclass__DOCUMENTATIONEXAMPLESansible.module_utils.basicr   r   r0   __name__r*   r   r   <module>r8      sF    A @;z& 58 D zF r   