经过多次努力,Ufff终于开始工作了:
cat /etc/puppetlabs/puppet/hiera.yaml --- version: 5 defaults: datadir: data data_hash: yaml_data hierarchy: - name: "Eyaml hierarchy" lookup_key: eyaml_lookup_key # eyaml backend paths: - "nodes/%{trusted.certname}.yaml" - "windowspass.eyaml" options: pkcs7_private_key: "/etc/puppetlabs/puppet/keys/private_key.pkcs7.pem" pkcs7_public_key: "/etc/puppetlabs/puppet/keys/public_key.pkcs7.pem
创建密码:
/opt/puppetlabs/puppet/bin/eyaml encrypt -l 'password' -s 'Pass' --pkcs7-public-key=/etc/puppetlabs/puppet/keys/public_key.pkcs7.pem --pkcs7-private-key=/etc/puppetlabs/puppet/keys/private_key.pkcs7.pem
将其添加到/etc/puppetlabs/puppet/data/windowspass.eyaml文件中:
/opt/puppetlabs/puppet/bin/eyaml edit windowspass.eyaml --pkcs7-public-key=/etc/puppetlabs/puppet/keys/public_key.pkcs7.pem --pkcs7-private-key=/etc/puppetlabs/puppet/keys/private_key.pkcs7.pem cat /etc/puppetlabs/puppet/data/windowspass.eyaml --- password: ENC[PKCS7,MIIBeQYJKoZIhvcNAQcDoIIBajCCAWYCAQAxggEhMIIBHQIBADAFMAACAQEwDQYJKoZIhvcNAQEBBQAEggEAUopetXenh/+DN1+VesIZUI5y4k3kOTn2xa5uBrtGZP3GvGqoWfwAbYsfeNApjeMG+lg93/N/6mE9T59DPh]
经过测试的解密:
/opt/puppetlabs/puppet/bin/eyaml decrypt -f windowspass.eyaml --pkcs7-public-key=/etc/puppetlabs/puppet/keys/public_key.pkcs7.pem --pkcs7-private-key=/etc/puppetlabs/puppet/keys/private_key.pkcs7.pem
正如Matt建议的那样,将windowspass.eyaml的内容映射到清单文件
'password' => Sensitive(lookup('password'))
调试命令帮了我很多忙:
puppet master --debug --compile windows.example.com --environment=production
谢谢大家,尤其是马特
首先,你的Hiera配置文件中有一个拼写错误。数据的路径应该是:
paths: - "/etc/common.eyaml"
修复之后,您需要从Hiera检索值。这是用。执行的 木偶查找功能 。由于您在单个数据文件中具有单个键值对,因此可以使用最少数量的参数执行此操作。
dsc_xADUser {'FirstUser': dsc_ensure => 'present', dsc_domainname => 'ad.contoso.com', dsc_username => 'tfl', dsc_userprincipalname => 'tfl@ad.contoso.com', dsc_password => { 'user' => 'Administrator@ad.contoso.com', 'password' => Sensitive('pass') }, dsc_passwordneverexpires => true, dsc_domainadministratorcredential => { 'user' => 'Administrator@ad.contoso.com', 'password' => lookup('string'), }, }
但是,您还希望从日志和报告中编辑该密码。您可能希望将该密码包装在一个 敏感数据类型 。
'password' => Sensitive(lookup('string')),
您似乎已经在为以字符串形式传递的其他密码执行此操作 pass 。
pass
所有这一切的一个附注是,Puppet在版本6中对Vault和Conjur的查找检索有内在的支持,因此很快就会成为最佳实践而不是hiera-eyaml。