community.general.credstash 查询 – 从 AWS 上的 Credstash 检索密钥
注意
此查询插件是 community.general 集合 (版本 10.1.0) 的一部分。
如果您使用的是 ansible
包,则可能已经安装了此集合。它不包含在 ansible-core
中。要检查是否已安装,请运行 ansible-galaxy collection list
。
要安装它,请使用: ansible-galaxy collection install community.general
。您需要其他要求才能使用此查询插件,有关详细信息,请参阅 要求。
要在 playbook 中使用它,请指定: community.general.credstash
。
概要
Credstash 是一个小型实用程序,用于使用 AWS 的 KMS 和 DynamoDB 管理密钥: https://github.com/fugue/credstash
要求
以下要求是在执行此查询的本地控制器节点上所需的。
credstash(python 库)
术语
参数 |
注释 |
---|---|
在信用存储中查找的术语或术语列表 |
关键字参数
这描述了查询的关键字参数。这些是在以下示例中的值 key1=value1
,key2=value2
等: lookup('community.general.credstash', key1=value1, key2=value2, ...)
和 query('community.general.credstash', key1=value1, key2=value2, ...)
参数 |
注释 |
---|---|
AWS 区域 |
|
要查询的 credstash 表的名称 默认值: |
|
Credstash 版本 默认值: |
备注
注意
当关键字和位置参数一起使用时,位置参数必须列在关键字参数之前:
lookup('community.general.credstash', term1, term2, key1=value1, key2=value2)
和query('community.general.credstash', term1, term2, key1=value1, key2=value2)
示例
- name: first use credstash to store your secrets
ansible.builtin.shell: credstash put my-github-password secure123
- name: "Test credstash lookup plugin -- get my github password"
ansible.builtin.debug:
msg: "Credstash lookup! {{ lookup('community.general.credstash', 'my-github-password') }}"
- name: "Test credstash lookup plugin -- get my other password from us-west-1"
ansible.builtin.debug:
msg: "Credstash lookup! {{ lookup('community.general.credstash', 'my-other-password', region='us-west-1') }}"
- name: "Test credstash lookup plugin -- get the company's github password"
ansible.builtin.debug:
msg: "Credstash lookup! {{ lookup('community.general.credstash', 'company-github-password', table='company-passwords') }}"
- name: Example play using the 'context' feature
hosts: localhost
vars:
context:
app: my_app
environment: production
tasks:
- name: "Test credstash lookup plugin -- get the password with a context passed as a variable"
ansible.builtin.debug:
msg: "{{ lookup('community.general.credstash', 'some-password', context=context) }}"
- name: "Test credstash lookup plugin -- get the password with a context defined here"
ansible.builtin.debug:
msg: "{{ lookup('community.general.credstash', 'some-password', context=dict(app='my_app', environment='production')) }}"
返回值
键 |
描述 |
---|---|
存储在 Credstash 中的值。 返回:成功 |