|
|
c235c4 |
From 563a03d94bfc29799ea964dab61a1ba35818b9bb Mon Sep 17 00:00:00 2001
|
|
|
c235c4 |
From: Sergio Oliveira Campos <seocam@seocam.com>
|
|
|
c235c4 |
Date: Thu, 30 Jul 2020 09:50:24 -0300
|
|
|
c235c4 |
Subject: [PATCH] Fixed error msgs on FreeIPABaseModule subclasses
|
|
|
c235c4 |
|
|
|
c235c4 |
When a fail_json is called a SystemExit exeception is raised.
|
|
|
c235c4 |
Since the FreeIPABaseModule has an internal context manager to deal
|
|
|
c235c4 |
with exceptions this ContextManager captures the SystemExit. After
|
|
|
c235c4 |
dealing destroying the kinit session the SystemExit must be raised again
|
|
|
c235c4 |
to allow the fail_json to work properly.
|
|
|
c235c4 |
---
|
|
|
c235c4 |
plugins/module_utils/ansible_freeipa_module.py | 9 ++++++---
|
|
|
c235c4 |
1 file changed, 6 insertions(+), 3 deletions(-)
|
|
|
c235c4 |
|
|
|
c235c4 |
diff --git a/plugins/module_utils/ansible_freeipa_module.py b/plugins/module_utils/ansible_freeipa_module.py
|
|
|
c235c4 |
index 122ea2e..a59e6e2 100644
|
|
|
c235c4 |
--- a/plugins/module_utils/ansible_freeipa_module.py
|
|
|
c235c4 |
+++ b/plugins/module_utils/ansible_freeipa_module.py
|
|
|
c235c4 |
@@ -610,12 +610,15 @@ class FreeIPABaseModule(AnsibleModule):
|
|
|
c235c4 |
exit the module with proper arguments.
|
|
|
c235c4 |
|
|
|
c235c4 |
"""
|
|
|
c235c4 |
- if exc_val:
|
|
|
c235c4 |
- self.fail_json(msg=str(exc_val))
|
|
|
c235c4 |
-
|
|
|
c235c4 |
# TODO: shouldn't we also disconnect from api backend?
|
|
|
c235c4 |
temp_kdestroy(self.ccache_dir, self.ccache_name)
|
|
|
c235c4 |
|
|
|
c235c4 |
+ if exc_type == SystemExit:
|
|
|
c235c4 |
+ raise
|
|
|
c235c4 |
+
|
|
|
c235c4 |
+ if exc_val:
|
|
|
c235c4 |
+ self.fail_json(msg=str(exc_val))
|
|
|
c235c4 |
+
|
|
|
c235c4 |
self.exit_json(changed=self.changed, user=self.exit_args)
|
|
|
c235c4 |
|
|
|
c235c4 |
def get_command_errors(self, command, result):
|
|
|
c235c4 |
--
|
|
|
c235c4 |
2.26.2
|
|
|
c235c4 |
|