【发布时间】:2021-10-13 09:56:10
【问题描述】:
我对我的 Ansible 清单有这样的想法:我只想拥有一个保管库值,一个种子,它可以生成我在清单中需要的所有密码。
类似这样的:
---
# I only have this to generate randomly, and vault
inventory_seed: "a strong random string"
# Then all my other password are derived from this seed.
# I feed the salted seed to a filter that creates a password directly sourced from the string I give him.
# will output, say, `wgSqz$@+SU^nw2;I` everytime I invoke ansible for the same inventory_hostname
machine_root_password: "{{ inventory_hostname + inventory_seed + 'root password' | to_strong_password }}"
# same: dp_password will be the same strong password everytime I invoke ansible
db_password: "{{ inventory_seed + 'db password' | to_strong_password }}"
# ... etc. All my inventory-specific passwords (and other keys) are derived from the same seed
这种方法有助于解决以下问题:
- 我有很多库存,但只有一组角色。
- 每次在角色中引入新密码时,我都必须为每个库存保存一个新密码。
我还将扩展它以生成密钥对、证书等。启动一个新的库存将减少到只指定一个或两个变量而不是几十个。
这是否存在于(综合)Jinja / Ansible 过滤器中?
我知道lookup( 'password', xxx) 方法,但这是不可重现的:如果提供了相同的种子,它不会将种子作为输入来输出相同的密码。我也知道这是一个经常被问到的问题,但是每次密码都保存在本地我不想要。
我必须自己实现吗?
您将如何扩展以生成其他合理但需要的数据(X509 证书、密钥对等)
【问题讨论】: