containers.podman.podman_logout 模块 – 使用 podman 注销容器镜像仓库

注意

此模块是 containers.podman 集合(版本 1.16.2)的一部分。

如果您使用的是 ansible 包,您可能已经安装了此集合。它不包含在 ansible-core 中。要检查是否已安装,请运行 ansible-galaxy collection list

要安装它,请使用:ansible-galaxy collection install containers.podman。您需要进一步的要求才能使用此模块,请参阅 要求 了解详细信息。

要在 playbook 中使用它,请指定:containers.podman.podman_logout

概要

  • 使用 podman logout 命令,通过删除存储在 `auth.json` 文件中的缓存凭据,注销容器镜像仓库服务器。如果未指定仓库,则将使用 `registries.conf` 中 `[registries.search]` 下的第一个仓库。用户可以通过设置 `authfile` 标志来覆盖身份验证文件的路径。使用的默认路径是 `${XDG_RUNTIME_DIR}/containers/auth.json`。可以通过设置 `all` 标志来删除所有缓存的凭据。警告 - 如果在默认 `authfile` 中找不到凭据,podman 将使用 `${HOME}/.docker/config.json` 中的凭据进行身份验证。但是,logout 命令只会删除指定 `authfile` 中的凭据。

要求

在执行此模块的主机上需要以下要求。

  • 主机上安装了 Podman

参数

参数

注释

all

布尔值

删除 auth 文件中所有仓库的缓存凭据。

选择

  • false

  • true

authfile

路径

身份验证文件的路径。默认值为 ``${XDG_RUNTIME_DIR}/containers/auth.json``。您还可以通过设置 ``REGISTRY_AUTH_FILE`` 环境变量来覆盖身份验证文件的默认路径。 ``export REGISTRY_AUTH_FILE=path``

executable

字符串

如果 podman 可执行文件不在运行 podman 的机器上的 $PATH 中,则指向该可执行文件的路径

默认值:"podman"

ignore_docker_credentials

布尔值

除非明确指定相应的 `authfile`,否则不会删除使用其他工具(如 `docker login`)创建的凭据。由于 podman 默认也使用这些文件中现有的凭据(例如,docker 的 `${HOME}/.docker/config.json`),如果 podman 使用的任何 `authfile` 中存在指定仓库的 docker 登录信息,则模块执行将失败。可以通过将 `ignore_docker_credentials` 设置为 `true` 来忽略此问题 - 将保留凭据,并且 `changed` 将为 false。此选项不能与 `all` 一起使用,因为在这种情况下,podman 不会检查其他工具创建的现有 `authfile`。

选择

  • false

  • true

registry

字符串

仓库服务器。如果未指定仓库,则将使用 `registries.conf` 中 `[registries.search]` 下的第一个仓库。

示例

- 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

作者

  • Clemens Lange (@clelange)