community.general.bitwarden_secrets_manager 查询 – 从 Bitwarden Secrets Manager 检索密钥
注意
此查询插件是 community.general 集合 (版本 10.1.0) 的一部分。
如果您使用的是 ansible 包,则您可能已经安装了此集合。它不包含在 ansible-core 中。要检查它是否已安装,请运行 ansible-galaxy collection list。
要安装它,请使用: ansible-galaxy collection install community.general。您需要其他要求才能使用此查询插件,有关详细信息,请参阅 要求。
要在剧本中使用它,请指定: community.general.bitwarden_secrets_manager。
community.general 7.2.0 中的新增功能
概要
- 从 Bitwarden Secrets Manager 检索密钥。 
要求
以下要求是在执行此查询的本地控制器节点上所需的。
- bws(命令行实用程序) 
术语
| 参数 | 注释 | 
|---|---|
| 要获取值的密钥 ID。 | 
关键字参数
这描述了查询的关键字参数。这些是在以下示例中的值 key1=value1,key2=value2 等等: lookup('community.general.bitwarden_secrets_manager', key1=value1, key2=value2, ...) 和 query('community.general.bitwarden_secrets_manager', key1=value1, key2=value2, ...)
| 参数 | 注释 | 
|---|---|
备注
注意
- 当一起使用关键字参数和位置参数时,必须先列出位置参数,然后再列出关键字参数: - lookup('community.general.bitwarden_secrets_manager', term1, term2, key1=value1, key2=value2)和- query('community.general.bitwarden_secrets_manager', term1, term2, key1=value1, key2=value2)
示例
- name: Get a secret relying on the BWS_ACCESS_TOKEN environment variable for authentication
  ansible.builtin.debug:
    msg: >-
      {{ lookup("community.general.bitwarden_secrets_manager", "2bc23e48-4932-40de-a047-5524b7ddc972") }}
- name: Get a secret passing an explicit access token for authentication
  ansible.builtin.debug:
    msg: >-
      {{
        lookup(
          "community.general.bitwarden_secrets_manager",
          "2bc23e48-4932-40de-a047-5524b7ddc972",
          bws_access_token="9.4f570d14-4b54-42f5-bc07-60f4450b1db5.YmluYXJ5LXNvbWV0aGluZy0xMjMK:d2h5IGhlbGxvIHRoZXJlCg=="
        )
      }}
- name: Get two different secrets each using a different access token for authentication
  ansible.builtin.debug:
    msg:
      - '{{ lookup("community.general.bitwarden_secrets_manager", "2bc23e48-4932-40de-a047-5524b7ddc972", bws_access_token=token1) }}'
      - '{{ lookup("community.general.bitwarden_secrets_manager", "9d89af4c-eb5d-41f5-bb0f-4ae81215c768", bws_access_token=token2) }}'
  vars:
    token1: "9.4f570d14-4b54-42f5-bc07-60f4450b1db5.YmluYXJ5LXNvbWV0aGluZy0xMjMK:d2h5IGhlbGxvIHRoZXJlCg=="
    token2: "1.69b72797-6ea9-4687-a11e-848e41a30ae6.YW5zaWJsZSBpcyBncmVhdD8K:YW5zaWJsZSBpcyBncmVhdAo="
- name: Get just the value of a secret
  ansible.builtin.debug:
    msg: >-
      {{ lookup("community.general.bitwarden_secrets_manager", "2bc23e48-4932-40de-a047-5524b7ddc972").value }}
返回值
| 键 | 描述 | 
|---|---|
| 包含一个或多个密钥的列表。 返回:成功 | 
