mirror of
https://github.com/spantaleev/matrix-docker-ansible-deploy.git
synced 2026-09-01 21:43:13 +00:00
Meowlnir (https://github.com/maunium/meowlnir) is a Matrix moderation bot which speaks the same policy-list protocol as Mjolnir and Draupnir, but runs as an appservice and can override individual policies coming from ban lists you do not control. Bots and their management rooms live only in Meowlnir's own database — nothing in its configuration file can declare one — so the role provisions them through the management API from a declarative roster (matrix_bot_meowlnir_bots_custom), applied under the ensure-matrix-users-created tag. Management rooms may be declared or created for you; bots and rooms no longer declared get pruned. Wrapper scripts for driving the management API by hand are installed to /matrix/meowlnir/bin. Meowlnir re-runs its configuration upgrader in memory on every start, so a literal `generate` value yields a new secret per restart. All secrets are therefore rendered explicitly, validation rejects `generate`, and the configuration directory is mounted read-only. Draupnir and Meowlnir both want synapse-http-antispam, which the playbook wires up to a single consumer. The wiring prefers Draupnir, and both roles fail the run when each claims it. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
58 lines
2.8 KiB
YAML
58 lines
2.8 KiB
YAML
# SPDX-FileCopyrightText: 2026 Slavi Pantaleev
|
|
#
|
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
---
|
|
|
|
# Only reached for bots with `management_room_auto_create` which do not have a management room yet.
|
|
# Meowlnir's own record of the bot's rooms is what makes this idempotent, so no state is kept on the Ansible side.
|
|
|
|
# Recomputed here, because validation runs its own loop over all bots and would leave this holding the last one's value.
|
|
- name: Determine the effective initial managers for a Meowlnir bot - {{ bot.username | quote }}
|
|
ansible.builtin.set_fact:
|
|
matrix_bot_meowlnir_bot_initial_managers: "{{ bot.initial_managers | default(matrix_bot_meowlnir_initial_managers) }}"
|
|
|
|
- name: Create a Meowlnir management room - {{ bot.username | quote }}
|
|
ansible.builtin.command:
|
|
cmd: >-
|
|
{{ matrix_bot_meowlnir_bin_path }}/meowlnir-create-management-room
|
|
{{ bot.username | quote }}
|
|
{{ matrix_bot_meowlnir_bot_initial_managers | map('quote') | join(' ') }}
|
|
register: matrix_bot_meowlnir_room_creation_result
|
|
# The script prints the new room's ID on success, so that is what tells us a room was actually created, not merely attempted.
|
|
changed_when: >-
|
|
matrix_bot_meowlnir_room_creation_result.rc == 0
|
|
and (matrix_bot_meowlnir_room_creation_result.stdout | default('') | trim).startswith('!')
|
|
failed_when: false
|
|
|
|
- name: Fail if the Meowlnir management room could not be created - {{ bot.username | quote }}
|
|
ansible.builtin.fail:
|
|
msg: >-
|
|
Creating a management room for the Meowlnir bot `{{ bot.username }}` failed.
|
|
{{ matrix_bot_meowlnir_room_creation_result.stdout | default('') | trim }}
|
|
{{ matrix_bot_meowlnir_room_creation_result.stderr | default('') | trim }}
|
|
when: >-
|
|
matrix_bot_meowlnir_room_creation_result.rc != 0
|
|
or not (matrix_bot_meowlnir_room_creation_result.stdout | default('') | trim).startswith('!')
|
|
|
|
- name: Register the created Meowlnir management room - {{ bot.username | quote }}
|
|
ansible.builtin.include_tasks: "{{ role_path }}/tasks/util/ensure_management_room_registered.yml"
|
|
vars:
|
|
management_room:
|
|
id: "{{ matrix_bot_meowlnir_room_creation_result.stdout | trim }}"
|
|
encrypted: "{{ matrix_bot_meowlnir_config_encryption_enable }}"
|
|
|
|
- name: Report the created Meowlnir management room - {{ bot.username | quote }}
|
|
ansible.builtin.set_fact:
|
|
devture_playbook_runtime_messages_list: >-
|
|
{{
|
|
devture_playbook_runtime_messages_list | default([])
|
|
+
|
|
[
|
|
"Note: created a management room (" ~ (matrix_bot_meowlnir_room_creation_result.stdout | trim) ~
|
|
") for the Meowlnir bot " ~ bot.username ~ " and invited " ~
|
|
(matrix_bot_meowlnir_bot_initial_managers | join(", ")) ~
|
|
" to it. Accept the invitation to start commanding the bot."
|
|
]
|
|
}}
|