-
Notifications
You must be signed in to change notification settings - Fork 89
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
Refactor openssl_privatekey module, move add openssl_privatekey_pipe module #119
Refactor openssl_privatekey module, move add openssl_privatekey_pipe module #119
Conversation
6fa52d0
to
c97065f
Compare
Isn't this functionality (ephemeral state) something that's more likely part of an action plugin? Also visible in logs or not, this will always transmit the private key material to the Ansible controller and the target host. It seems to me that this is something that you shouldn't run on remote hosts anyways (you only might want to assign the task to the host to get some context/host_vars). Implementing this as action plugin however is a LOT more pain than one might initially expect, just as a fair warning. I don't have a better name than the Maybe there's also the option of adding a |
@MarkusTeufelberger I'd think the module will be mostly used for Making it an action plugin is a good idea in this case, though I wanted to do the same extension to other modules as well, most prominently About adding a
I agree that |
I'll look into changing this to an action plugin later. I think it should not be that hard, with a proper bit of framework code for argument validation. Fortunately most of that has already been moved out ot AnsibleModule into generic validation functionality in https://github.com/ansible/ansible/tree/devel/lib/ansible/module_utils/common/ |
I've changed the module to an action plugin. For that, I've added a small framework (mostly copy'n'pasta from ansible.module_utils.basic) which provides similar argument validation facilities as AnsibleModule. |
4100beb
to
2da5ab9
Compare
ready_for_review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't find much, maybe a few ideas to consider or things to clarify. Hope it helps, I think it can also be merged as-is.
9f9e1d5
to
855369e
Compare
Looks good to me, thanks for all the work! /shipit |
@MarkusTeufelberger thanks a lot for reviewing this! |
SUMMARY
openssl_privatekey_pipe
is providing almost the same functionality thanopenssl_privatekey
, except that it does not operate on disk. An existing private key can (optionally) be passed into the module (for idempotency checks, or for conversion), and the new/converted/unchanged private key is returned, but not written to disk.This allows to store key data in vaults without having to write the unprotected key to disk (for example with the community.sops collection).
For this, I moved the main code from
openssl_privatekey
to plugins/module_utils/crypto/module_backends/privatekey.py, and the corresponding documentation to plugins/doc_fragments/module_privatekey.py.I'm not 100% sure about the
_pipe
suffix. If someone has a better idea, feel free to mention it :)ISSUE TYPE
COMPONENT NAME
openssl_privatekey
openssl_privatekey_pipe