mirror of
https://github.com/spantaleev/matrix-docker-ansible-deploy.git
synced 2026-10-20 21:34:15 +00:00
Containers are created with `--rm`, so Docker removes them asynchronously after they stop. The pre-start `docker rm` returns immediately while that removal is still in progress (its error is suppressed), and the following `docker create --name` can fail with "The container name ... is already in use". This is easy to hit since systemd_service_manager switched its default restart mode to `all-at-once`: many containers stop and start at the same time and Docker falls behind on removals. The playbook then fails at "Restart systemd services needing restart at once", even though the services recover on their own (`Restart=always`) a little later. The external roles (MASH, devture) were hardened against this in 2026-03 (see mother-of-all-self-hosting/ansible-role-valkey@0ba79c0), but the roles in `roles/custom` never were. This ports the same bounded cleanup loop to them: stop, force-remove, and wait until Docker releases the name, failing explicitly after a timeout. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
170 lines
10 KiB
YAML
170 lines
10 KiB
YAML
# SPDX-FileCopyrightText: 2020 - 2025 Slavi Pantaleev
|
|
# SPDX-FileCopyrightText: 2021 - 2022 MDAD project contributors
|
|
# SPDX-FileCopyrightText: 2021 Ahmad Haghighi
|
|
# SPDX-FileCopyrightText: 2021 Richard Meyer
|
|
# SPDX-FileCopyrightText: 2022 Marko Weltzer
|
|
# SPDX-FileCopyrightText: 2022 Nikita Chernyi
|
|
# SPDX-FileCopyrightText: 2023 Samuel Meenzen
|
|
#
|
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
---
|
|
# matrix-reminder-bot is a bot for one-off and recurring reminders
|
|
# Project source code URL: https://github.com/anoadragon453/matrix-reminder-bot
|
|
|
|
matrix_bot_matrix_reminder_bot_enabled: true
|
|
|
|
matrix_bot_matrix_reminder_bot_container_image_self_build: false
|
|
matrix_bot_matrix_reminder_bot_container_repo: "https://github.com/anoadragon453/matrix-reminder-bot.git"
|
|
matrix_bot_matrix_reminder_bot_container_repo_version: "{{ 'master' if matrix_bot_matrix_reminder_bot_version == 'latest' else matrix_bot_matrix_reminder_bot_version }}"
|
|
matrix_bot_matrix_reminder_bot_container_src_files_path: "{{ matrix_base_data_path }}/matrix-reminder-bot/docker-src"
|
|
|
|
# renovate: datasource=docker depName=ghcr.io/anoadragon453/matrix-reminder-bot
|
|
matrix_bot_matrix_reminder_bot_version: v0.4.0
|
|
matrix_bot_matrix_reminder_bot_container_image: "{{ matrix_bot_matrix_reminder_bot_container_image_registry_prefix }}anoadragon453/matrix-reminder-bot:{{ matrix_bot_matrix_reminder_bot_version }}"
|
|
matrix_bot_matrix_reminder_bot_container_image_registry_prefix: "{{ 'localhost/' if matrix_bot_matrix_reminder_bot_container_image_self_build else matrix_bot_matrix_reminder_bot_container_image_registry_prefix_upstream }}"
|
|
matrix_bot_matrix_reminder_bot_container_image_registry_prefix_upstream: "{{ matrix_bot_matrix_reminder_bot_container_image_registry_prefix_upstream_default }}"
|
|
matrix_bot_matrix_reminder_bot_container_image_registry_prefix_upstream_default: "ghcr.io/"
|
|
|
|
matrix_bot_matrix_reminder_bot_base_path: "{{ matrix_base_data_path }}/matrix-reminder-bot"
|
|
matrix_bot_matrix_reminder_bot_config_path: "{{ matrix_bot_matrix_reminder_bot_base_path }}/config"
|
|
matrix_bot_matrix_reminder_bot_data_path: "{{ matrix_bot_matrix_reminder_bot_base_path }}/data"
|
|
matrix_bot_matrix_reminder_bot_data_store_path: "{{ matrix_bot_matrix_reminder_bot_data_path }}/store"
|
|
|
|
matrix_bot_matrix_reminder_bot_command_prefix: "!"
|
|
|
|
# A list of extra arguments to pass to the container
|
|
matrix_bot_matrix_reminder_bot_container_extra_arguments: []
|
|
|
|
# Controls how long the pre-start cleanup should wait for stale container-name release
|
|
# before failing startup explicitly.
|
|
matrix_bot_matrix_reminder_bot_container_cleanup_timeout_seconds: "{{ devture_systemd_docker_base_container_cleanup_timeout_seconds }}"
|
|
|
|
# Controls the delay between pre-start cleanup retries.
|
|
matrix_bot_matrix_reminder_bot_container_cleanup_retry_delay_seconds: "{{ devture_systemd_docker_base_container_cleanup_retry_delay_seconds }}"
|
|
|
|
# Shell command used in the systemd pre-start phase to deterministically remove a stale
|
|
# container and wait until Docker releases its name.
|
|
matrix_bot_matrix_reminder_bot_container_cleanup_command: |
|
|
i=0;
|
|
while [ "$i" -lt {{ matrix_bot_matrix_reminder_bot_container_cleanup_timeout_seconds }} ]; do
|
|
{{ devture_systemd_docker_base_host_command_docker }} stop -t {{ devture_systemd_docker_base_container_stop_grace_time_seconds }} matrix-bot-matrix-reminder-bot >/dev/null 2>&1 || true;
|
|
{{ devture_systemd_docker_base_host_command_docker }} rm -f matrix-bot-matrix-reminder-bot >/dev/null 2>&1 || true;
|
|
if {{ devture_systemd_docker_base_host_command_docker }} container inspect matrix-bot-matrix-reminder-bot >/dev/null 2>&1; then
|
|
i=$((i + 1));
|
|
sleep {{ matrix_bot_matrix_reminder_bot_container_cleanup_retry_delay_seconds }};
|
|
continue;
|
|
fi;
|
|
if {{ devture_systemd_docker_base_host_command_docker }} info >/dev/null 2>&1; then
|
|
exit 0;
|
|
fi;
|
|
echo "Failed to query Docker daemon while cleaning up matrix-bot-matrix-reminder-bot" >&2;
|
|
exit 1;
|
|
done;
|
|
echo "Failed to remove stale container matrix-bot-matrix-reminder-bot after {{ matrix_bot_matrix_reminder_bot_container_cleanup_timeout_seconds }} attempts" >&2;
|
|
exit 1
|
|
|
|
matrix_bot_matrix_reminder_bot_container_network: ""
|
|
|
|
matrix_bot_matrix_reminder_bot_container_additional_networks: "{{ matrix_bot_matrix_reminder_bot_container_additional_networks_auto + matrix_bot_matrix_reminder_bot_container_additional_networks_custom }}"
|
|
matrix_bot_matrix_reminder_bot_container_additional_networks_auto: []
|
|
matrix_bot_matrix_reminder_bot_container_additional_networks_custom: []
|
|
|
|
# List of systemd services that matrix-bot-matrix-reminder-bot.service depends on
|
|
matrix_bot_matrix_reminder_bot_systemd_required_services_list: "{{ matrix_bot_matrix_reminder_bot_systemd_required_services_list_default + matrix_bot_matrix_reminder_bot_systemd_required_services_list_auto + matrix_bot_matrix_reminder_bot_systemd_required_services_list_custom }}"
|
|
matrix_bot_matrix_reminder_bot_systemd_required_services_list_default: "{{ [devture_systemd_docker_base_docker_service_name] if devture_systemd_docker_base_docker_service_name else [] }}"
|
|
matrix_bot_matrix_reminder_bot_systemd_required_services_list_auto: []
|
|
matrix_bot_matrix_reminder_bot_systemd_required_services_list_custom: []
|
|
|
|
# List of systemd services that matrix-bot-matrix-reminder-bot.service wants
|
|
matrix_bot_matrix_reminder_bot_systemd_wanted_services_list: []
|
|
|
|
# Database-related configuration fields.
|
|
#
|
|
# To use SQLite, stick to these defaults.
|
|
#
|
|
# To use Postgres:
|
|
# - change the engine (`matrix_bot_matrix_reminder_bot_database_engine: 'postgres'`)
|
|
# - adjust your database credentials via the `matrix_bot_matrix_reminder_bot_database_*` variables
|
|
matrix_bot_matrix_reminder_bot_database_engine: 'sqlite'
|
|
|
|
matrix_bot_matrix_reminder_bot_sqlite_database_path_local: "{{ matrix_bot_matrix_reminder_bot_data_path }}/bot.db"
|
|
matrix_bot_matrix_reminder_bot_sqlite_database_path_in_container: "/data/bot.db"
|
|
|
|
matrix_bot_matrix_reminder_bot_database_username: 'matrix_reminder_bot'
|
|
matrix_bot_matrix_reminder_bot_database_password: 'some-password'
|
|
matrix_bot_matrix_reminder_bot_database_hostname: ''
|
|
matrix_bot_matrix_reminder_bot_database_port: 5432
|
|
matrix_bot_matrix_reminder_bot_database_name: 'matrix_reminder_bot'
|
|
|
|
matrix_bot_matrix_reminder_bot_database_connection_string: 'postgres://{{ matrix_bot_matrix_reminder_bot_database_username }}:{{ matrix_bot_matrix_reminder_bot_database_password }}@{{ matrix_bot_matrix_reminder_bot_database_hostname }}:{{ matrix_bot_matrix_reminder_bot_database_port }}/{{ matrix_bot_matrix_reminder_bot_database_name }}'
|
|
|
|
matrix_bot_matrix_reminder_bot_storage_database: "{{ {
|
|
'sqlite': ('sqlite://' + matrix_bot_matrix_reminder_bot_sqlite_database_path_in_container),
|
|
'postgres': matrix_bot_matrix_reminder_bot_database_connection_string,
|
|
}[matrix_bot_matrix_reminder_bot_database_engine] }}"
|
|
|
|
|
|
# The bot's username. This user needs to be created manually beforehand.
|
|
# Also see `matrix_bot_matrix_reminder_bot_user_password`.
|
|
matrix_bot_matrix_reminder_bot_matrix_user_id_localpart: "bot.matrix-reminder-bot"
|
|
|
|
matrix_bot_matrix_reminder_bot_matrix_user_id: '@{{ matrix_bot_matrix_reminder_bot_matrix_user_id_localpart }}:{{ matrix_domain }}'
|
|
|
|
# The password that the bot uses to authenticate.
|
|
matrix_bot_matrix_reminder_bot_matrix_user_password: ''
|
|
|
|
matrix_bot_matrix_reminder_bot_matrix_homeserver_url: ""
|
|
|
|
# The timezone to use when creating reminders.
|
|
# Examples: 'Europe/London', 'Etc/UTC'
|
|
matrix_bot_matrix_reminder_bot_reminders_timezone: ''
|
|
|
|
matrix_bot_matrix_reminder_bot_allowlist_enabled: false
|
|
matrix_bot_matrix_reminder_bot_allowlist_regexes: "{{ matrix_bot_matrix_reminder_bot_allowlist_regexes_auto + matrix_bot_matrix_reminder_bot_allowlist_regexes_custom }}"
|
|
matrix_bot_matrix_reminder_bot_allowlist_regexes_auto: []
|
|
matrix_bot_matrix_reminder_bot_allowlist_regexes_custom: []
|
|
|
|
# If both the blocklist and whitelist are enabled at the same time, the blocklist takes precedence.
|
|
matrix_bot_matrix_reminder_bot_blocklist_enabled: false
|
|
matrix_bot_matrix_reminder_bot_blocklist_regexes: "{{ matrix_bot_matrix_reminder_bot_blocklist_regexes_auto + matrix_bot_matrix_reminder_bot_blocklist_regexes_custom }}"
|
|
matrix_bot_matrix_reminder_bot_blocklist_regexes_auto: []
|
|
matrix_bot_matrix_reminder_bot_blocklist_regexes_custom: []
|
|
|
|
# Default configuration template which covers the generic use case.
|
|
# You can customize it by controlling the various variables inside it.
|
|
#
|
|
# For a more advanced customization, you can extend the default (see `matrix_bot_matrix_reminder_bot_configuration_extension_yaml`)
|
|
# or completely replace this variable with your own template.
|
|
matrix_bot_matrix_reminder_bot_configuration_yaml: "{{ lookup('template', 'templates/config.yaml.j2') }}"
|
|
|
|
matrix_bot_matrix_reminder_bot_configuration_extension_yaml: |
|
|
# Your custom YAML configuration goes here.
|
|
# This configuration extends the default starting configuration (`matrix_bot_matrix_reminder_bot_configuration_yaml`).
|
|
#
|
|
# You can override individual variables from the default configuration, or introduce new ones.
|
|
#
|
|
# If you need something more special, you can take full control by
|
|
# completely redefining `matrix_bot_matrix_reminder_bot_configuration_yaml`.
|
|
#
|
|
# Example configuration extension follows:
|
|
#
|
|
# matrix:
|
|
# device_name: My-Reminder-Bot
|
|
|
|
matrix_bot_matrix_reminder_bot_configuration_extension: "{{ matrix_bot_matrix_reminder_bot_configuration_extension_yaml | from_yaml if matrix_bot_matrix_reminder_bot_configuration_extension_yaml | from_yaml is mapping else {} }}"
|
|
|
|
# Holds the final configuration (a combination of the default and its extension).
|
|
# You most likely don't need to touch this variable. Instead, see `matrix_bot_matrix_reminder_bot_configuration_yaml`.
|
|
matrix_bot_matrix_reminder_bot_configuration: "{{ matrix_bot_matrix_reminder_bot_configuration_yaml | from_yaml | combine(matrix_bot_matrix_reminder_bot_configuration_extension, recursive=True) }}"
|
|
|
|
# matrix_bot_matrix_reminder_bot_restart_necessary controls whether the service
|
|
# will be restarted (when true) or merely started (when false) by the
|
|
# systemd service manager role (when conditional restart is enabled).
|
|
#
|
|
# This value is automatically computed during installation based on whether
|
|
# any configuration files, the systemd service file, or the container image changed.
|
|
# The default of `false` means "no restart needed" — appropriate when the role's
|
|
# installation tasks haven't run (e.g., due to --tags skipping them).
|
|
matrix_bot_matrix_reminder_bot_restart_necessary: false
|