community.general.keyring 模块 – 使用操作系统的原生密钥环设置或删除密码

注意

此模块是 community.general 集合(版本 10.1.0)的一部分。

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

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

要在 playbook 中使用它,请指定:community.general.keyring

community.general 5.2.0 中的新功能

概要

  • 此模块使用 keyring Python 库 从操作系统的原生密钥环设置或删除给定服务和用户名的密码。

要求

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

  • keyring (Python 库)

  • gnome-keyring(应用程序 - 无头 Gnome 密钥环访问需要)

  • dbus-run-session(应用程序 - 无头 Gnome 密钥环访问需要)

参数

参数

注释

keyring_password

字符串 / 必需

用于解锁密钥环的密码。

服务

字符串 / 必需

服务的名称。

状态

字符串

密码是否应该存在。

选择

  • "present" ←(默认)

  • "absent"

user_password

别名:password

字符串

要设置的密码。

用户名

字符串 / 必需

属于服务的用户。

属性

属性

支持

描述

check_mode

支持:完整

可以在 check_mode 中运行并返回更改状态预测,而无需修改目标。

diff_mode

支持:

在 diff 模式下,将返回已更改的内容(或可能需要在 check_mode 中更改的内容)的详细信息。

示例

- name: Set a password for test/test1
  community.general.keyring:
    service: test
    username: test1
    user_password: "{{ user_password }}"
    keyring_password: "{{ keyring_password }}"

- name: Delete the password for test/test1
  community.general.keyring:
    service: test
    username: test1
    user_password: "{{ user_password }}"
    keyring_password: "{{ keyring_password }}"
    state: absent

作者

  • Alexander Hussey (@ahussey-redhat)