mirror of
https://github.com/famedly/ansible-collection-matrix
synced 2024-11-10 05:34:16 +00:00
fix(modules/matrix): Handle login / logout corrently
This commit is contained in:
parent
e065948d58
commit
ee56b991fa
2 changed files with 8 additions and 5 deletions
|
@ -43,7 +43,7 @@ class AnsibleNioModule:
|
|||
add_file_common_args=False,
|
||||
supports_check_mode=True,
|
||||
required_if=None,
|
||||
user_logout=True):
|
||||
user_logout=None):
|
||||
|
||||
if required_by is None:
|
||||
required_by = {'password': 'user_id'}
|
||||
|
@ -57,9 +57,6 @@ class AnsibleNioModule:
|
|||
if custom_spec is None:
|
||||
custom_spec = {}
|
||||
|
||||
# If a user/password login is provided, should we logout when exiting?
|
||||
self.user_logout = user_logout
|
||||
|
||||
# Create the Ansible module
|
||||
self.module = AnsibleModule(
|
||||
argument_spec=AnsibleNioModule.__common_argument_spec(custom_spec),
|
||||
|
@ -74,6 +71,12 @@ class AnsibleNioModule:
|
|||
required_by=required_by
|
||||
)
|
||||
|
||||
if user_logout is None:
|
||||
# If a user/password login is provided, should we logout when exiting?
|
||||
self.user_logout = self.module.params['token'] is not None
|
||||
else:
|
||||
self.user_logout = user_logout
|
||||
|
||||
# Make some values from the module easly accessible
|
||||
self.check_mode = self.module.check_mode
|
||||
self.params = self.module.params
|
||||
|
|
|
@ -66,7 +66,7 @@ async def run_module():
|
|||
changed=False,
|
||||
)
|
||||
|
||||
module = AnsibleNioModule()
|
||||
module = AnsibleNioModule(user_logout=True)
|
||||
await module.matrix_login()
|
||||
await module.matrix_logout()
|
||||
await module.exit_json(**result)
|
||||
|
|
Loading…
Reference in a new issue