-
Notifications
You must be signed in to change notification settings - Fork 90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add saving private key ansible-vault encrypted #805
Comments
openssl_privatekey is a module, not an action plugin, so it has no access to Ansible Vault. There are very few action plugins which support using Ansible Vault, and all I'm aware of only allow to read Vault encrypted stuff. (The only Ansible plugin I'm aware of that encrypts is the To implement what you want to do, you should use the The openssl_privatekey_pipe examples (https://docs.ansible.com/ansible/devel/collections/community/crypto/openssl_privatekey_pipe_module.html#examples) shows how to combine the module with community.sops to (re-)generate a SOPS encrypted key, if necessary. Combining it with Ansible Vault should go similarly. (If you figure out how to combine them you could add another example to the module, I'm sure this will be useful for other users as well.) |
Hmm, that could work. It's a bit more effort to not have it overwritten but should work. But just a dumb thought, just adding ansible-vault as an optional dependency for this feature wouldn't work? So that the vault encryption isn't done on the controller but on the target (which then may be delegated to e.g. localhost or to a specific CA-VM)? |
On the controller you cannot access the parts of ansible-core that handle vault, and you also don't have access to the vault password used by the controller. |
SUMMARY
Enable
community.crypto.openssl_privatekey
to save the private key using ansible-vault encryption.ISSUE TYPE
COMPONENT NAME
community.crypto.openssl_privatekey
ADDITIONAL INFORMATION
My current usage may be a bit unusual but what I was trying to do was create a task within the roll that generates the private key for an internal CA to sign stuff but store that private key within the playbook on the controller. Aka. If a private key does not exist within a specific variable name it'll create one and add an additional yaml file to the playbook that contains said variable with the newly generated private key so that it'll be persistent for future runs but still allow the playbook to be a template for multiple similar projects (It doesn't have to be a yaml file and a variable directly, just an ansible-vault encrypted file/asset would already be enough).
Also being able to have the module store the private key using ansible-vault encryption could be quite useful for a bunch of other usages as well as it is may more secure than just being able to secure it using a passphrase.
The text was updated successfully, but these errors were encountered: