5
0
mirror of https://github.com/spantaleev/matrix-docker-ansible-deploy.git synced 2026-08-19 23:30:51 +00:00
Files
matrix-docker-ansible-deploy/roles/custom/matrix-bot-meowlnir/tasks/util/read_meowlnir_state.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

30 lines
1.3 KiB
YAML

# SPDX-FileCopyrightText: 2026 Slavi Pantaleev
#
# SPDX-License-Identifier: AGPL-3.0-or-later
---
# Meowlnir's own database is the source of truth for which bots and management rooms exist, and it can be queried, so the playbook keeps no state of its own about them.
- name: Ask Meowlnir which bots currently exist
ansible.builtin.command:
cmd: "{{ matrix_bot_meowlnir_bin_path }}/meowlnir-api GET /_meowlnir/v1/bots"
register: matrix_bot_meowlnir_state_result
changed_when: false
failed_when: false
- name: Fail if Meowlnir could not be asked which bots exist
ansible.builtin.fail:
msg: >-
Could not read the list of bots from Meowlnir.
Meowlnir said: {{ matrix_bot_meowlnir_state_result.stdout | default('') | trim }}
{{ matrix_bot_meowlnir_state_result.stderr | default('') | trim }}
when: >-
matrix_bot_meowlnir_state_result.rc != 0
or (matrix_bot_meowlnir_state_result.stdout_lines | default([]) | length == 0)
or (matrix_bot_meowlnir_state_result.stdout_lines | last != '200')
- name: Determine which bots and management rooms Meowlnir knows about
ansible.builtin.set_fact:
matrix_bot_meowlnir_live_bots: "{{ (matrix_bot_meowlnir_state_result.stdout_lines[:-1] | join('\n') | from_json).bots | default([], true) }}"