mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
openssl_certificate: fix state=absent (#54298)
* Fix state=absent. * Add changelog.
This commit is contained in:
parent
afca42bc6d
commit
534c833bb3
2 changed files with 78 additions and 59 deletions
|
@ -0,0 +1,2 @@
|
|||
bugfixes:
|
||||
- "openssl_certificate - fix ``state=absent``."
|
|
@ -691,6 +691,18 @@ class Certificate(crypto_utils.OpenSSLObject):
|
|||
|
||||
return True
|
||||
|
||||
def dump(self, check_mode=False):
|
||||
# Use only for absent
|
||||
|
||||
result = {
|
||||
'changed': self.changed,
|
||||
'filename': self.path,
|
||||
'privatekey': self.privatekey_path,
|
||||
'csr': self.csr_path
|
||||
}
|
||||
|
||||
return result
|
||||
|
||||
|
||||
class SelfSignedCertificateCryptography(Certificate):
|
||||
"""Generate the self-signed certificate, using the cryptography backend"""
|
||||
|
@ -1841,6 +1853,11 @@ def main():
|
|||
add_file_common_args=True,
|
||||
)
|
||||
|
||||
if module.params['state'] == 'absent':
|
||||
# backend doesn't matter
|
||||
certificate = Certificate(module, 'cryptography')
|
||||
|
||||
else:
|
||||
if module.params['provider'] != 'assertonly' and module.params['csr_path'] is None:
|
||||
module.fail_json(msg='csr_path is required when provider is not assertonly')
|
||||
|
||||
|
|
Loading…
Reference in a new issue