5
0
mirror of https://github.com/spantaleev/matrix-docker-ansible-deploy.git synced 2026-08-14 04:40:51 +00:00
Files
matrix-docker-ansible-deploy/roles/custom/matrix-bot-meowlnir/tasks/setup_bots.yml
T
Slavi Pantaleev f9222dc70c Add support for Meowlnir
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>
2026-08-13 06:05:30 +03:00

36 lines
1.5 KiB
YAML

# SPDX-FileCopyrightText: 2026 Slavi Pantaleev
#
# SPDX-License-Identifier: AGPL-3.0-or-later
---
# Validation lives in validate_config.yml so that it also runs on regular setup/install runs, catching mistakes long before anyone reaches for the `ensure-matrix-users-created` tag.
# It is repeated here because this tag can be run on its own, and creating a bot outside the appservice's user namespace fails in ways that are hard to trace back.
- name: Validate matrix-bot-meowlnir configuration before creating bots
ansible.builtin.include_tasks: "{{ role_path }}/tasks/validate_config.yml"
- name: Ensure matrix-bot-meowlnir is started before creating bots
ansible.builtin.service:
name: matrix-bot-meowlnir.service
state: started
daemon_reload: true
register: matrix_bot_meowlnir_start_result
- name: Wait a while, so that Meowlnir can manage to start before creating bots
ansible.builtin.pause:
seconds: "{{ matrix_bot_meowlnir_bots_start_wait_time_seconds }}"
when: matrix_bot_meowlnir_start_result.changed | bool
- name: Read which bots Meowlnir already has
ansible.builtin.include_tasks: "{{ role_path }}/tasks/util/read_meowlnir_state.yml"
- name: Ensure Meowlnir bots created
ansible.builtin.include_tasks: "{{ role_path }}/tasks/util/ensure_bot_created.yml"
with_items: "{{ matrix_bot_meowlnir_bots }}"
loop_control:
loop_var: bot
- name: Remove Meowlnir bots which are no longer declared
ansible.builtin.include_tasks: "{{ role_path }}/tasks/util/prune_bots.yml"
when: matrix_bot_meowlnir_bots_pruning_enabled | bool