fix: allow to call exit/fail from check-mode

This commit is contained in:
Johanna Dorothea Reichmann 2023-01-30 13:04:18 +01:00
parent a4361b1623
commit bf7f2328e9
No known key found for this signature in database
GPG key ID: 03624C433676E465

View file

@ -154,13 +154,15 @@ class AnsibleNioModule:
async def exit_json(self, **result):
if self.module.params.get("token") is None and self.user_logout is True:
await self.matrix_logout()
await self.client.close()
if not self.module.check_mode:
await self.client.close()
self.module.exit_json(**result)
async def fail_json(self, **result):
if self.module.params.get("token") is None and self.user_logout is True:
await self.matrix_logout()
await self.client.close()
if not self.module.check_mode:
await self.client.close()
self.module.fail_json(**result)
@staticmethod