2020-01-20 16:11:02 +00:00
|
|
|
#!/usr/bin/python
|
|
|
|
# coding: utf-8
|
|
|
|
|
|
|
|
# (c) 2018, Jan Christian Grünhage <jan.christian@gruenhage.xyz>
|
2021-04-10 10:59:25 +00:00
|
|
|
# (c) 2020-2021, Famedly GmbH
|
2020-02-10 17:23:03 +00:00
|
|
|
# GNU Affero General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/agpl-3.0.txt)
|
2020-01-20 16:11:02 +00:00
|
|
|
|
2022-08-10 11:27:01 +00:00
|
|
|
from __future__ import absolute_import, division, print_function
|
2022-07-29 08:47:49 +00:00
|
|
|
|
2020-01-20 16:11:02 +00:00
|
|
|
__metaclass__ = type
|
|
|
|
|
|
|
|
ANSIBLE_METADATA = {
|
2022-08-10 11:27:01 +00:00
|
|
|
"metadata_version": "1.1",
|
|
|
|
"status": ["preview"],
|
|
|
|
"supported_by": "community",
|
2020-01-20 16:11:02 +00:00
|
|
|
}
|
|
|
|
|
2022-08-10 11:27:01 +00:00
|
|
|
DOCUMENTATION = """
|
2020-01-20 16:11:02 +00:00
|
|
|
---
|
|
|
|
author: "Jan Christian Grünhage (@jcgruenhage)"
|
2020-02-14 11:42:54 +00:00
|
|
|
module: matrix_logout
|
2020-01-20 16:11:02 +00:00
|
|
|
short_description: Log out of matrix
|
|
|
|
description:
|
|
|
|
- Invalidate an access token by logging out
|
|
|
|
options:
|
|
|
|
hs_url:
|
|
|
|
description:
|
|
|
|
- URL of the homeserver, where the CS-API is reachable
|
|
|
|
required: true
|
2022-07-29 08:47:49 +00:00
|
|
|
type: str
|
|
|
|
user_id:
|
|
|
|
description:
|
|
|
|
- The user id of the user
|
|
|
|
required: false
|
|
|
|
type: str
|
|
|
|
password:
|
|
|
|
description:
|
|
|
|
- The password to log in with
|
|
|
|
required: false
|
|
|
|
type: str
|
2020-01-20 16:11:02 +00:00
|
|
|
token:
|
|
|
|
description:
|
|
|
|
- Authentication token for the API call
|
2022-07-29 08:47:49 +00:00
|
|
|
required: false
|
|
|
|
type: str
|
2020-01-20 16:11:02 +00:00
|
|
|
requirements:
|
2020-02-10 17:23:03 +00:00
|
|
|
- matrix-nio (Python library)
|
2022-08-10 11:27:01 +00:00
|
|
|
"""
|
2020-01-20 16:11:02 +00:00
|
|
|
|
2022-08-10 11:27:01 +00:00
|
|
|
EXAMPLES = """
|
2020-01-20 16:11:02 +00:00
|
|
|
- name: Invalidate access token
|
2020-02-14 11:42:54 +00:00
|
|
|
matrix_logout:
|
2020-01-20 16:11:02 +00:00
|
|
|
hs_url: "https://matrix.org"
|
|
|
|
token: "{{ matrix_auth_token }}"
|
2022-08-10 11:27:01 +00:00
|
|
|
"""
|
2020-01-20 16:11:02 +00:00
|
|
|
|
2022-08-10 11:27:01 +00:00
|
|
|
RETURN = """
|
|
|
|
"""
|
2020-02-10 17:23:03 +00:00
|
|
|
import asyncio
|
2020-01-20 16:11:02 +00:00
|
|
|
|
2022-08-10 11:27:01 +00:00
|
|
|
from ansible_collections.famedly.matrix.plugins.module_utils.matrix import (
|
|
|
|
AnsibleNioModule,
|
|
|
|
)
|
2022-07-29 08:47:49 +00:00
|
|
|
|
|
|
|
|
2020-02-10 17:23:03 +00:00
|
|
|
async def run_module():
|
2020-01-20 16:11:02 +00:00
|
|
|
result = dict(
|
|
|
|
changed=False,
|
|
|
|
)
|
|
|
|
|
2022-08-01 09:38:22 +00:00
|
|
|
module = AnsibleNioModule(user_logout=True)
|
2021-04-10 10:59:25 +00:00
|
|
|
await module.matrix_login()
|
|
|
|
await module.matrix_logout()
|
|
|
|
await module.exit_json(**result)
|
2020-01-20 16:11:02 +00:00
|
|
|
|
|
|
|
|
|
|
|
def main():
|
2020-02-10 17:23:03 +00:00
|
|
|
asyncio.run(run_module())
|
2020-01-20 16:11:02 +00:00
|
|
|
|
2022-07-29 08:47:49 +00:00
|
|
|
|
2022-08-10 11:27:01 +00:00
|
|
|
if __name__ == "__main__":
|
2020-01-20 16:11:02 +00:00
|
|
|
main()
|