openssl_privatekey: add backup option (#53593)

* Add backup option to openssl_privatekey.

* Add changelog fragment.

* Make module available in remove().

* Add tests for backup.

* Update lib/ansible/modules/crypto/openssl_privatekey.py

Co-Authored-By: felixfontein <felix@fontein.de>

* Update lib/ansible/modules/crypto/openssl_privatekey.py

Co-Authored-By: felixfontein <felix@fontein.de>

* Update lib/ansible/modules/crypto/openssl_privatekey.py

Co-Authored-By: felixfontein <felix@fontein.de>

* Update lib/ansible/modules/crypto/openssl_privatekey.py
This commit is contained in:
Felix Fontein 2019-03-18 17:34:47 +01:00 committed by John R Barker
commit e00f315358
9 changed files with 81 additions and 11 deletions

View file

@ -205,7 +205,7 @@ class PublicKey(crypto_utils.OpenSSLObject):
except (IOError, OSError) as exc:
raise PublicKeyError(exc)
except AttributeError as exc:
self.remove()
self.remove(module)
raise PublicKeyError('You need to have PyOpenSSL>=16.0.0 to generate public keys')
self.fingerprint = crypto_utils.get_fingerprint(
@ -315,7 +315,7 @@ def main():
module.exit_json(**result)
try:
public_key.remove()
public_key.remove(module)
except PublicKeyError as exc:
module.fail_json(msg=to_native(exc))