简体   繁体   English

Ansible 创建加密文件到现有保管库

[英]Ansible create encrypted file to an existing vault

I created an encrypted file with ansible vault like so:我使用 ansible 保管库创建了一个加密文件,如下所示:

ansible-vault create encrypted-example-file1

It seems that ansible creates a new vault here, because it asks for new Vault password from me.似乎 ansible 在这里创建了一个新的保险库,因为它要求我提供新的保险库密码。 That is ok, I gave a password for the new Vault to be created.没关系,我为要创建的新 Vault 提供了密码。 This all seems working fine, I give the password to get the file decrypted during playbook run.这一切似乎都很好,我提供了密码以在 playbook 运行期间解密文件。

Now I want to create another encrypted file, and I would like to store it to the same vault I created earlier, so that I wouldn't need a separate password for the second file.现在我想创建另一个加密文件,我想将它存储到我之前创建的同一个保管库中,这样我就不需要为第二个文件设置单独的密码了。 How to do that?怎么做? I tried to repeat the command:我试图重复命令:

ansible-vault create encrypted-example-file2

But the problem is that it again asks new vault password , which indicates it wishes me to create yet another vault?但问题是它再次询问新的保险库密码,这表明它希望我创建另一个保险库? I don't want to do that.我不想那样做。 So how can I apply the existing ansible vault for the new encrypted file?那么如何将现有的 ansible 库应用于新的加密文件? I tried reading the ansible docs but did not catch any guide on how to do it.我尝试阅读 ansible 文档,但没有找到任何有关如何操作的指南。

Ansible vaults works for file encryption or variable encryption. Ansible 保险库适用于文件加密或变量加密。 If you want to encrypt a different file then you have to provide password again to encrypt the file using ansible vault.如果要加密不同的文件,则必须再次提供密码才能使用 ansible 保管库加密文件。 You can use the same password for file1 and file2.您可以对 file1 和 file2 使用相同的密码。 While executing playbook ansible will decrypt both files using the same password.在执行 playbook ansible 时,将使用相同的密码解密这两个文件。

It's also possible to edit the encrypted encrypted-example-file1 using ansible-vault edit command then add additional content of encrypted-example-file2 for encryption.也可以使用ansible-vault edit命令编辑加密的encrypted-example-file1 ,然后添加encrypted-example-file2的附加内容进行加密。

ansible-vault edit encrypted-example-file1

Here are more details. 这里有更多细节。

You do not necessarily have to type the password every time you use ansible-vault .您不必每次使用ansible-vault时都输入密码。

ansible, ansible-playbook, and ansible-vault all have --vault-password-file=VAULT_PASSWORD_FILES parameter that you can use to specify a file in which you store the password. ansible、ansible-playbook 和--vault-password-file=VAULT_PASSWORD_FILES参数,可用于指定存储密码的文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM