ansible-collection-famedly-.../plugins/modules
2022-01-20 11:28:42 +01:00
..
matrix_login.py refactor(modules): add matrix_utils.AnsibleNioModule helper class, edit all modules accordingly 2021-04-19 10:14:49 +02:00
matrix_logout.py refactor(modules): add matrix_utils.AnsibleNioModule helper class, edit all modules accordingly 2021-04-19 10:14:49 +02:00
matrix_member.py refactor(modules): add matrix_utils.AnsibleNioModule helper class, edit all modules accordingly 2021-04-19 10:14:49 +02:00
matrix_notification.py refactor(modules): add matrix_utils.AnsibleNioModule helper class, edit all modules accordingly 2021-04-19 10:14:49 +02:00
matrix_room.py refactor(modules): add matrix_utils.AnsibleNioModule helper class, edit all modules accordingly 2021-04-19 10:14:49 +02:00
matrix_signing_key.py refactor(modules): fix lots of pylint warnings 2020-10-02 20:34:15 +02:00
matrix_state.py refactor(modules): add matrix_utils.AnsibleNioModule helper class, edit all modules accordingly 2021-04-19 10:14:49 +02:00
matrix_uia_login.py fix(matrix-uia-login): pick correct stage when multiple stages are available. 2022-01-20 11:28:42 +01:00
README.md feat(modules): add synapse_register module 2020-10-09 17:35:06 +02:00
synapse_ratelimit.py feat(synapse_ratelimit): add initial module 2021-06-02 13:25:25 +02:00
synapse_register.py feat(modules): add synapse_register module 2020-10-09 17:35:06 +02:00

Matrix Ansible Modules

These are a few ansible modules for working with matrix rooms.

Requirements

  • nio: The modules require matrix-nio to be required on the target. Some bugs and missing features were found during the development of these modules, which have been fixed in the case of bugs and implemented in the case of missing features. Until they are merged upstream, you have to install the matrix-nio library from source using https://github.com/poljar/matrix-nio/pull/102.
  • Python >= 3.5: The modules make extensive use of async/await, so only Python 3.5 or later are supported. These modules have only been tested with Python 3.8 so far.

Example Playbook

- hosts: localhost
  collections:
    - famedly.matrix
  gather_facts: false
  vars:
    matrix:
      homeserver: "https://example.org"
      user: "some_user"
      password: "s3cr3t"
      alias: "#module-tests:example.org"
      invitees:
        - '@another_user:example.org'
        - '@a_third_user:example.org'
  tasks:
    - synapse_register:
        hs_url: "{{ matrix.homeserver }}"
        user_id: "{{ matrix.user }}"
        password: "{{ matrix.password }}"
        admin: false
        shared_secret: "iqueok1zeengieW3ohcha0riePaigh9p"
    - matrix_login:
        hs_url: "{{ matrix.homeserver }}"
        user_id: "{{ matrix.user }}"
        password: "{{ matrix.password }}"
      register: login_result
    - matrix_room:
        hs_url: "{{ matrix.homeserver }}"
        token: "{{ login_result.token }}"
        alias: "{{ matrix.alias }}"
      register: room_result
    - matrix_state:
        hs_url: "{{ matrix.homeserver }}"
        token: "{{ login_result.token }}"
        room_id: "{{ room_result.room_id }}"
        event_type: "m.room.name"
        state_key: ""
        content:
          name: "test room name"
      register: state_result
    - matrix_member:
        hs_url: "{{ matrix.homeserver }}"
        token: "{{ login_result.token }}"
        room_id: "{{ room_result.room_id }}"
        user_ids: "{{ matrix.invitees }}"
        state: "member"
        exclusive: False
      register: membership_changes
    - matrix_notification:
        hs_url: "{{ matrix.homeserver }}"
        token: "{{ login_result.token }}"
        room_id: "{{ room_result.room_id }}"
        msg_plain: "Updated memberships: {{ membership_changes | to_json }}"
        msg_html: "Updated memberships: {{ membership_changes | to_json }}"
      when: membership_changes.changed
    - matrix_logout:
        hs_url: "{{ matrix.homeserver }}"
        token: "{{ login_result.token }}"