community.general.onepassword_info 模块 – 从 1Password 收集项目
注意
此模块是 community.general 集合 (版本 10.1.0) 的一部分。
如果您正在使用 ansible
包,则您可能已经安装了此集合。它不包含在 ansible-core
中。要检查它是否已安装,请运行 ansible-galaxy collection list
。
要安装它,请使用:ansible-galaxy collection install community.general
。您需要其他要求才能使用此模块,请参阅 需求 获取详细信息。
要在剧本中使用它,请指定:community.general.onepassword_info
。
概要
community.general.onepassword_info 封装了
op
命令行实用程序,用于获取一个或多个 1Password 项目的数据。如果找不到任何正在搜索的项目,则会发生致命错误。
建议与
no_log
选项一起使用,以避免记录正在检索的密钥的值。
需求
以下是执行此模块的主机所需的条件。
op
1Password 命令行实用程序。请参阅 https://support.1password.com/command-line/
参数
参数 |
注释 |
---|---|
包含身份验证详细信息的字典。如果设置了此选项,community.general.onepassword_info 将尝试自动登录到 1Password。 没有此选项,您必须在运行 Ansible 之前已经通过 1Password CLI 登录。 强烈建议将 1Password 凭据存储在 Ansible Vault 中。确保用于加密 Ansible Vault 的密钥强度等于或大于 1Password 主密码。 |
|
子域的主密码。 指定 |
|
子域的密钥。 仅初始登录时需要。 |
|
1Password 子域名称 (<subdomain>.1password.com)。 如果未指定此参数,则将使用最近的子域。 |
|
1Password 用户名。 仅初始登录时需要。 |
|
用于指定 默认值: |
|
一个或多个搜索词的列表。 每个搜索词可以是一个简单的字符串,也可以是一个字典以获得更多控制。 传递简单字符串时, 传递字典时,可以使用以下字段。 |
|
要在该项目中搜索的字段名称(可选,默认为“password”(如果项目有附件,则默认为“document”)。 |
|
要搜索的 1Password 项目的名称(必需)。 |
|
包含指定字段的项目内部分区的名称(可选,如果未指定,则搜索所有分区)。 |
|
要搜索的特定 1Password 存储库的名称,如果您的 1Password 用户可以访问多个存储库,则此参数很有用(可选)。 |
属性
属性 |
支持 |
描述 |
---|---|---|
支持:完全支持 此操作不会修改状态。 |
可以在 |
|
支持:N/A 此操作不会修改状态。 |
在差异模式下,将返回有关已更改内容(或可能需要在 |
备注
注意
已使用
op
版本 0.5.5 测试基于Scott Buchanan <sbuchanan@ri.pn> 编写的community.general.onepassword查找插件。
示例
# Gather secrets from 1Password, assuming there is a 'password' field:
- name: Get a password
community.general.onepassword_info:
search_terms: My 1Password item
delegate_to: localhost
register: my_1password_item
no_log: true # Don't want to log the secrets to the console!
# Gather secrets from 1Password, with more advanced search terms:
- name: Get a password
community.general.onepassword_info:
search_terms:
- name: My 1Password item
field: Custom field name # optional, defaults to 'password'
section: Custom section name # optional, defaults to 'None'
vault: Name of the vault # optional, only necessary if there is more than 1 Vault available
delegate_to: localhost
register: my_1password_item
no_log: true # Don't want to log the secrets to the console!
# Gather secrets combining simple and advanced search terms to retrieve two items, one of which we fetch two
# fields. In the first 'password' is fetched, as a field name is not specified (default behaviour) and in the
# second, 'Custom field name' is fetched, as that is specified explicitly.
- name: Get a password
community.general.onepassword_info:
search_terms:
- My 1Password item # 'name' is optional when passing a simple string...
- name: My Other 1Password item # ...but it can also be set for consistency
- name: My 1Password item
field: Custom field name # optional, defaults to 'password'
section: Custom section name # optional, defaults to 'None'
vault: Name of the vault # optional, only necessary if there is more than 1 Vault available
- name: A 1Password item with document attachment
delegate_to: localhost
register: my_1password_item
no_log: true # Don't want to log the secrets to the console!
- name: Debug a password (for example)
ansible.builtin.debug:
msg: "{{ my_1password_item['onepassword']['My 1Password item'] }}"
返回值
常见的返回值已在此处记录,以下是此模块特有的字段
键 |
描述 |
---|---|
匹配给定搜索条件的每个 1Password 项目的字典,显示了上面第三个示例中返回的内容。 返回:成功 示例: |