From 5bb8a36f341ebfc85051ab86ea078333621e260f Mon Sep 17 00:00:00 2001 From: Catalan Lover Date: Wed, 12 Mar 2025 21:51:21 +0100 Subject: [PATCH 01/11] Update Mjolnir Anti Spam module to latest and add Renovate --- roles/custom/matrix-synapse/defaults/main.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/roles/custom/matrix-synapse/defaults/main.yml b/roles/custom/matrix-synapse/defaults/main.yml index 29338cf31..9147e127d 100644 --- a/roles/custom/matrix-synapse/defaults/main.yml +++ b/roles/custom/matrix-synapse/defaults/main.yml @@ -1331,7 +1331,8 @@ matrix_synapse_ext_spam_checker_synapse_simple_antispam_config_blocked_homeserve # See: https://github.com/matrix-org/mjolnir#synapse-module matrix_synapse_ext_spam_checker_mjolnir_antispam_enabled: false matrix_synapse_ext_spam_checker_mjolnir_antispam_git_repository_url: "https://github.com/matrix-org/mjolnir" -matrix_synapse_ext_spam_checker_mjolnir_antispam_git_version: "v1.6.4" +# renovate: datasource=docker depName=matrixdotorg/mjolnir +matrix_synapse_ext_spam_checker_mjolnir_antispam_git_version: "v1.9.2" matrix_synapse_ext_spam_checker_mjolnir_antispam_config_block_invites: true # Flag messages sent by servers/users in the ban lists as spam. Currently # this means that spammy messages will appear as empty to users. Default From dc581d0b7aaae11cf6cdd9bbf2a9c73bc0d3b22f Mon Sep 17 00:00:00 2001 From: Suguru Hirahara Date: Thu, 13 Mar 2025 05:04:56 +0000 Subject: [PATCH 02/11] Add ensure-users-created to the list of available tags on playbook-tags.md (#4169) --- docs/playbook-tags.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/playbook-tags.md b/docs/playbook-tags.md index 42d2354d6..48e61f73c 100644 --- a/docs/playbook-tags.md +++ b/docs/playbook-tags.md @@ -27,7 +27,7 @@ Here are some playbook tags that you should be familiar with: - `stop` — stops all systemd services -- `ensure-matrix-users-created` — a special tag which ensures that all special users needed by the playbook (for bots, etc.) are created +- `ensure-matrix-users-created` or its alias `ensure-users-created` — a special tag which ensures that all special users needed by the playbook (for bots, etc.) are created **Notes**: - `setup-*` tags and `install-*` tags **do not start services** automatically, because you may wish to do things before starting services, such as importing a database dump, restoring data from another server, etc. From 0086ae7f58b39ab8f39af5b2df3b6ee83cf08a92 Mon Sep 17 00:00:00 2001 From: Catalan Lover <48515417+FSG-Cat@users.noreply.github.com> Date: Thu, 13 Mar 2025 19:20:09 +0100 Subject: [PATCH 03/11] Update D4A Configuration (#4166) * Update D4A Configuration D4A had some breaking config changes so this commit fixes them and gets us back into compliance with upstream. And since we run in a docker container we can use the /data/storage default. * Update D4A Configuration to harmonise with bot mode Change the default config for D4A to align with bot mode default in mdad. This should also avert a bit of a mess of a potential bug. * Change D4A Room State Backing Store variable name and fix SPDX Headers * Align D4A config with new schema * Fix D4A Config Lint Error * Update D4A SPDX Entries * Do not use double quotes around `to_json` values --------- Co-authored-by: Slavi Pantaleev --- .../defaults/main.yml | 13 +++++++------ .../tasks/main.yml | 1 + .../tasks/setup_install.yml | 1 + .../tasks/setup_uninstall.yml | 1 + .../tasks/validate_config.yml | 3 +++ .../templates/production-appservice.yaml.j2 | 9 ++++++++- .../templates/production-bots.yaml.j2 | 18 ++++++++++++++++++ ...service-draupnir-for-all.service.j2.license | 1 + 8 files changed, 40 insertions(+), 7 deletions(-) diff --git a/roles/custom/matrix-appservice-draupnir-for-all/defaults/main.yml b/roles/custom/matrix-appservice-draupnir-for-all/defaults/main.yml index a1eebf5af..17e415f6c 100644 --- a/roles/custom/matrix-appservice-draupnir-for-all/defaults/main.yml +++ b/roles/custom/matrix-appservice-draupnir-for-all/defaults/main.yml @@ -1,4 +1,5 @@ -# SPDX-FileCopyrightText: 2024 - 2025 MDAD project contributors +# SPDX-FileCopyrightText: 2024 MDAD project contributors +# SPDX-FileCopyrightText: 2024 - 2025 Catalan Lover # SPDX-FileCopyrightText: 2024 - 2025 Slavi Pantaleev # SPDX-FileCopyrightText: 2024 Suguru Hirahara # @@ -51,12 +52,12 @@ matrix_appservice_draupnir_for_all_systemd_wanted_services_list: [] # Note: Draupnir is fairly verbose - expect a lot of messages from it. # This room is diffrent for Appservice Mode compared to normal mode. # In Appservice mode it provides functions like user management. -matrix_appservice_draupnir_for_all_master_control_room_alias: "" +matrix_appservice_draupnir_for_all_config_adminRoom: "" # noqa var-naming -# Placeholder Remenant of the fact that Cat belived Master Control Room to be separated from Access Control Policy List. -# The alias of the Policy list used to control who can provision a bot for them selfs. -# This should be a room alias - not a matrix.to URL. -# matrix_appservice_draupnir_for_all_management_policy_list_alias: "" +# Controls if the room state backing store is activated. +# Room state backing store makes restarts of the bot lightning fast as the bot does not suffer from amnesia. +# This config option has diminished improvements for bots on extremely fast homeservers or very very small bots on fast homeservers. +matrix_appservice_draupnir_for_all_config_roomStateBackingStore_enabled: false # noqa var-naming matrix_appservice_draupnir_for_all_database_username: matrix_appservice_draupnir_for_all matrix_appservice_draupnir_for_all_database_password: 'some-passsword' diff --git a/roles/custom/matrix-appservice-draupnir-for-all/tasks/main.yml b/roles/custom/matrix-appservice-draupnir-for-all/tasks/main.yml index 5e4af332b..51f5fe4f2 100644 --- a/roles/custom/matrix-appservice-draupnir-for-all/tasks/main.yml +++ b/roles/custom/matrix-appservice-draupnir-for-all/tasks/main.yml @@ -1,4 +1,5 @@ # SPDX-FileCopyrightText: 2024 MDAD project contributors +# SPDX-FileCopyrightText: 2024 Catalan Lover # # SPDX-License-Identifier: AGPL-3.0-or-later diff --git a/roles/custom/matrix-appservice-draupnir-for-all/tasks/setup_install.yml b/roles/custom/matrix-appservice-draupnir-for-all/tasks/setup_install.yml index e4d51b7f7..12781f5dc 100644 --- a/roles/custom/matrix-appservice-draupnir-for-all/tasks/setup_install.yml +++ b/roles/custom/matrix-appservice-draupnir-for-all/tasks/setup_install.yml @@ -1,5 +1,6 @@ # SPDX-FileCopyrightText: 2024 David Mehren # SPDX-FileCopyrightText: 2024 MDAD project contributors +# SPDX-FileCopyrightText: 2024 Catalan Lover # SPDX-FileCopyrightText: 2024 Slavi Pantaleev # SPDX-FileCopyrightText: 2024 Suguru Hirahara # diff --git a/roles/custom/matrix-appservice-draupnir-for-all/tasks/setup_uninstall.yml b/roles/custom/matrix-appservice-draupnir-for-all/tasks/setup_uninstall.yml index da78634d6..4ad172539 100644 --- a/roles/custom/matrix-appservice-draupnir-for-all/tasks/setup_uninstall.yml +++ b/roles/custom/matrix-appservice-draupnir-for-all/tasks/setup_uninstall.yml @@ -1,4 +1,5 @@ # SPDX-FileCopyrightText: 2023 - 2024 MDAD project contributors +# SPDX-FileCopyrightText: 2024 Catalan Lover # # SPDX-License-Identifier: AGPL-3.0-or-later diff --git a/roles/custom/matrix-appservice-draupnir-for-all/tasks/validate_config.yml b/roles/custom/matrix-appservice-draupnir-for-all/tasks/validate_config.yml index 8d8d1168c..72f86a7ef 100644 --- a/roles/custom/matrix-appservice-draupnir-for-all/tasks/validate_config.yml +++ b/roles/custom/matrix-appservice-draupnir-for-all/tasks/validate_config.yml @@ -1,4 +1,5 @@ # SPDX-FileCopyrightText: 2024 MDAD project contributors +# SPDX-FileCopyrightText: 2024 Catalan Lover # SPDX-FileCopyrightText: 2024 Slavi Pantaleev # SPDX-FileCopyrightText: 2025 Suguru Hirahara # @@ -22,3 +23,5 @@ when: "item.old in vars" with_items: - {'old': 'matrix_appservice_draupnir_for_all_docker_image_name_prefix', 'new': 'matrix_appservice_draupnir_for_all_docker_image_registry_prefix'} + - {'old': 'matrix_appservice_draupnir_for_all_enable_room_state_backing_store', 'new': 'matrix_appservice_draupnir_for_all_config_roomStateBackingStore_enabled'} + - {'old': 'matrix_appservice_draupnir_for_all_master_control_room_alias', 'new': 'matrix_appservice_draupnir_for_all_config_adminRoom'} diff --git a/roles/custom/matrix-appservice-draupnir-for-all/templates/production-appservice.yaml.j2 b/roles/custom/matrix-appservice-draupnir-for-all/templates/production-appservice.yaml.j2 index 346b57e96..ea168dac9 100644 --- a/roles/custom/matrix-appservice-draupnir-for-all/templates/production-appservice.yaml.j2 +++ b/roles/custom/matrix-appservice-draupnir-for-all/templates/production-appservice.yaml.j2 @@ -1,5 +1,6 @@ {# SPDX-FileCopyrightText: 2024 MDAD project contributors +SPDX-FileCopyrightText: 2024 - 2025 Catalan Lover SPDX-FileCopyrightText: 2024 Suguru Hirahara SPDX-License-Identifier: AGPL-3.0-or-later @@ -18,8 +19,14 @@ db: # A room you have created that scopes who can access the appservice. # See docs/access_control.md -adminRoom: "{{ matrix_appservice_draupnir_for_all_master_control_room_alias }}" +adminRoom: {{ matrix_appservice_draupnir_for_all_config_adminRoom | to_json }} # This is a web api that the widget connects to in order to interact with the appservice. webAPI: port: 9000 + +# The directory the bot should store various bits of information in +dataPath: "/data" + +roomStateBackingStore: + enabled: {{ matrix_appservice_draupnir_for_all_config_roomStateBackingStore_enabled | to_json }} diff --git a/roles/custom/matrix-appservice-draupnir-for-all/templates/production-bots.yaml.j2 b/roles/custom/matrix-appservice-draupnir-for-all/templates/production-bots.yaml.j2 index de581ed8e..63eb20b22 100644 --- a/roles/custom/matrix-appservice-draupnir-for-all/templates/production-bots.yaml.j2 +++ b/roles/custom/matrix-appservice-draupnir-for-all/templates/production-bots.yaml.j2 @@ -1,5 +1,6 @@ {# SPDX-FileCopyrightText: 2024 MDAD project contributors +SPDX-FileCopyrightText: 2024 - 2025 Catalan Lover SPDX-License-Identifier: AGPL-3.0-or-later #} @@ -73,3 +74,20 @@ commands: - "brigading" - "harassment" - "disagreement" + +# Safe mode provides recovery options for some failure modes when Draupnir +# fails to start. For example, if the bot fails to resolve a room alias in +# a watched list, or if the server has parted from a protected room and can't +# find a way back in. Safe mode will provide different options to recover from +# these. Such as unprotecting the room or unwatching the policy list. +# By default Draupnir will boot into safe mode only when the failure mode +# is recoverable. +# It may be desirable to prevent the bot from starting into safe mode if you have +# a pager system when Draupnir is down, as Draupnir could prevent your monitoring +# system from identifying a failure to start. +#safeMode: +# # The option for entering safe mode when Draupnir fails to start up. +# # - "RecoveryOnly" will only start the bot in safe mode when there are recovery options available. This is the default. +# # - "Never" will never start the bot in safe mode when Draupnir fails to start normally. +# # - "Always" will always start the bot in safe mode when Draupnir fails to start normally. +# bootOption: RecoveryOnly diff --git a/roles/custom/matrix-appservice-draupnir-for-all/templates/systemd/matrix-appservice-draupnir-for-all.service.j2.license b/roles/custom/matrix-appservice-draupnir-for-all/templates/systemd/matrix-appservice-draupnir-for-all.service.j2.license index c66c5baed..b39d4ce53 100644 --- a/roles/custom/matrix-appservice-draupnir-for-all/templates/systemd/matrix-appservice-draupnir-for-all.service.j2.license +++ b/roles/custom/matrix-appservice-draupnir-for-all/templates/systemd/matrix-appservice-draupnir-for-all.service.j2.license @@ -1,4 +1,5 @@ SPDX-FileCopyrightText: 2024 MDAD project contributors +SPDX-FileCopyrightText: 2024 Catalan Lover SPDX-FileCopyrightText: 2024 Slavi Pantaleev SPDX-License-Identifier: AGPL-3.0-or-later From 166f4127837ce1debfb7d60268255e08539b4a98 Mon Sep 17 00:00:00 2001 From: Catalan Lover <48515417+FSG-Cat@users.noreply.github.com> Date: Thu, 13 Mar 2025 19:25:30 +0100 Subject: [PATCH 04/11] Modernise Draupnir Configuration Variable Names (#4170) * Modernise Draupnir Configuration Variable Names * Move Draupnir deprecation-check task before undefined-variables-check * Fix trailing spaces in Draupnir's `validate_config.yml` --------- Co-authored-by: Slavi Pantaleev --- docs/configuring-playbook-bot-draupnir.md | 10 ++--- group_vars/matrix_servers | 6 +-- group_vars/matrix_servers.license | 2 +- .../matrix-bot-draupnir/defaults/main.yml | 25 ++++++----- .../custom/matrix-bot-draupnir/tasks/main.yml | 1 + .../tasks/setup_install.yml | 1 + .../tasks/setup_uninstall.yml | 1 + .../tasks/validate_config.yml | 43 ++++++++++++------- .../templates/production.yaml.j2 | 21 ++++----- .../matrix-bot-draupnir.service.j2.license | 1 + 10 files changed, 65 insertions(+), 46 deletions(-) diff --git a/docs/configuring-playbook-bot-draupnir.md b/docs/configuring-playbook-bot-draupnir.md index 92f5c5969..8465dcbd8 100644 --- a/docs/configuring-playbook-bot-draupnir.md +++ b/docs/configuring-playbook-bot-draupnir.md @@ -58,7 +58,7 @@ matrix_bot_draupnir_enable_experimental_rust_crypto: true # Access token which the bot will use for logging in. # Comment out `matrix_bot_draupnir_login_native` when using this option. -matrix_bot_draupnir_access_token: "CLEAN_ACCESS_TOKEN_HERE" +matrix_bot_draupnir_config_accessToken: "CLEAN_ACCESS_TOKEN_HERE" ``` ## Adjusting the playbook configuration @@ -73,13 +73,13 @@ matrix_bot_draupnir_enabled: true # matrix_bot_draupnir_login: bot.draupnir # Generate a strong password for the bot. You can create one with a command like `pwgen -s 64 1`. -# If creating the user on your own and using `matrix_bot_draupnir_access_token` to login you can comment out this line. +# If creating the user on your own and using `matrix_bot_draupnir_config_accessToken` to login you can comment out this line. matrix_bot_draupnir_password: PASSWORD_FOR_THE_BOT -# Comment out if using `matrix_bot_draupnir_enable_experimental_rust_crypto: true` or `matrix_bot_draupnir_access_token` to login. +# Comment out if using `matrix_bot_draupnir_enable_experimental_rust_crypto: true` or `matrix_bot_draupnir_config_accessToken` to login. matrix_bot_draupnir_login_native: true -matrix_bot_draupnir_management_room: "MANAGEMENT_ROOM_ID_HERE" +matrix_bot_draupnir_config_managementRoom: "MANAGEMENT_ROOM_ID_HERE" ``` ### Create and invite the bot to the management room @@ -142,7 +142,7 @@ Draupnir can receive reports in the management room. The bot can intercept the report API endpoint of the client-server API, which requires integration with the reverse proxy in front of the homeserver. If you are using Traefik, this playbook can set this up for you: ```yaml -matrix_bot_draupnir_abuse_reporting_enabled: true +matrix_bot_draupnir_config_web_abuseReporting: true ```