mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-25 14:20:22 -07:00
openssl_dhparam: fix state=absent (#54296)
* Fix remove. * Add changelog.
This commit is contained in:
parent
5db7501ebd
commit
121990d8c5
2 changed files with 14 additions and 4 deletions
2
changelogs/fragments/54296-openssl_dhparam-remove.yaml
Normal file
2
changelogs/fragments/54296-openssl_dhparam-remove.yaml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
bugfixes:
|
||||||
|
- "openssl_dhparam - fix ``state=absent`` idempotency and ``changed`` flag."
|
|
@ -136,6 +136,13 @@ class DHParameter(object):
|
||||||
|
|
||||||
self.changed = changed
|
self.changed = changed
|
||||||
|
|
||||||
|
def remove(self, module):
|
||||||
|
try:
|
||||||
|
os.remove(self.path)
|
||||||
|
self.changed = True
|
||||||
|
except OSError as exc:
|
||||||
|
module.fail_json(msg=to_native(exc))
|
||||||
|
|
||||||
def check(self, module):
|
def check(self, module):
|
||||||
"""Ensure the resource is in its desired state."""
|
"""Ensure the resource is in its desired state."""
|
||||||
if self.force:
|
if self.force:
|
||||||
|
@ -223,10 +230,11 @@ def main():
|
||||||
result['changed'] = os.path.exists(module.params['path'])
|
result['changed'] = os.path.exists(module.params['path'])
|
||||||
module.exit_json(**result)
|
module.exit_json(**result)
|
||||||
|
|
||||||
try:
|
if os.path.exists(module.params['path']):
|
||||||
os.remove(module.params['path'])
|
try:
|
||||||
except OSError as exc:
|
dhparam.remove(module)
|
||||||
module.fail_json(msg=to_native(exc))
|
except Exception as exc:
|
||||||
|
module.fail_json(msg=to_native(exc))
|
||||||
|
|
||||||
result = dhparam.dump()
|
result = dhparam.dump()
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue