ansible-collection-famedly-.../plugins/modules
Lars Kaiser 9dbd99a305
feat(matrix_member): support force join for local users
Requires synapse as homeserver.
2023-03-30 20:41:50 +02:00
..
matrix_login.py chore(plugins): format with black and add CI job for checking 2022-08-10 18:34:26 +02:00
matrix_logout.py chore(plugins): format with black and add CI job for checking 2022-08-10 18:34:26 +02:00
matrix_member.py feat(matrix_member): support force join for local users 2023-03-30 20:41:50 +02:00
matrix_notification.py fix: check-mode in modules behaves properly 2023-01-31 08:54:24 +01:00
matrix_room.py fix: check-mode in modules behaves properly 2023-01-31 08:54:24 +01:00
matrix_signing_key.py chore(plugins): format with black and add CI job for checking 2022-08-10 18:34:26 +02:00
matrix_state.py fix: check-mode in modules behaves properly 2023-01-31 08:54:24 +01:00
matrix_token_login.py fix(matrix_token_login): handle admin flag in check_mode 2023-02-09 09:53:45 +01:00
matrix_uia_login.py chore(plugins): format with black and add CI job for checking 2022-08-10 18:34:26 +02:00
README.md feat(modules): add synapse_register module 2020-10-09 17:35:06 +02:00
synapse_ratelimit.py chore(plugins): format with black and add CI job for checking 2022-08-10 18:34:26 +02:00
synapse_register.py chore(plugins): format with black and add CI job for checking 2022-08-10 18:34:26 +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 }}"