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>
102 lines
5.8 KiB
YAML
102 lines
5.8 KiB
YAML
# SPDX-FileCopyrightText: 2024 - 2025 Slavi Pantaleev
|
|
# SPDX-FileCopyrightText: 2024 - 2025 Suguru Hirahara
|
|
#
|
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
---
|
|
# E2EE aware proxy daemon for Matrix clients.
|
|
# Project source code URL: https://github.com/matrix-org/pantalaimon
|
|
|
|
matrix_pantalaimon_enabled: true
|
|
|
|
matrix_pantalaimon_version: "0.10.5"
|
|
|
|
matrix_pantalaimon_container_image_self_build: false
|
|
matrix_pantalaimon_container_image_self_build_repo: "https://github.com/matrix-org/pantalaimon.git"
|
|
matrix_pantalaimon_container_image_self_build_repo_version: "{{ 'main' if matrix_pantalaimon_version == 'latest' else matrix_pantalaimon_version }}"
|
|
|
|
matrix_pantalaimon_container_image: "{{ matrix_pantalaimon_container_image_registry_prefix }}matrixdotorg/pantalaimon:v{{ matrix_pantalaimon_version }}"
|
|
matrix_pantalaimon_container_image_registry_prefix: "{{ 'localhost/' if matrix_pantalaimon_container_image_self_build else matrix_pantalaimon_container_image_registry_prefix_upstream }}"
|
|
matrix_pantalaimon_container_image_registry_prefix_upstream: "{{ matrix_pantalaimon_container_image_registry_prefix_upstream_default }}"
|
|
matrix_pantalaimon_container_image_registry_prefix_upstream_default: "docker.io/"
|
|
|
|
matrix_pantalaimon_base_path: "{{ matrix_base_data_path }}/pantalaimon"
|
|
matrix_pantalaimon_data_path: "{{ matrix_pantalaimon_base_path }}/data"
|
|
matrix_pantalaimon_container_src_files_path: "{{ matrix_pantalaimon_base_path }}/container-src"
|
|
|
|
# The base container network
|
|
matrix_pantalaimon_container_network: ''
|
|
|
|
# A list of additional container networks that the container would be connected to.
|
|
# The role does not create these networks, so make sure they already exist.
|
|
matrix_pantalaimon_container_additional_networks: "{{ matrix_pantalaimon_container_additional_networks_auto + matrix_pantalaimon_container_additional_networks_custom }}"
|
|
matrix_pantalaimon_container_additional_networks_auto: []
|
|
matrix_pantalaimon_container_additional_networks_custom: []
|
|
|
|
# A list of extra arguments to pass to the container
|
|
matrix_pantalaimon_container_extra_arguments: []
|
|
|
|
# Controls how long the pre-start cleanup should wait for stale container-name release
|
|
# before failing startup explicitly.
|
|
matrix_pantalaimon_container_cleanup_timeout_seconds: "{{ devture_systemd_docker_base_container_cleanup_timeout_seconds }}"
|
|
|
|
# Controls the delay between pre-start cleanup retries.
|
|
matrix_pantalaimon_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_pantalaimon_container_cleanup_command: |
|
|
i=0;
|
|
while [ "$i" -lt {{ matrix_pantalaimon_container_cleanup_timeout_seconds }} ]; do
|
|
{{ devture_systemd_docker_base_host_command_docker }} stop -t {{ devture_systemd_docker_base_container_stop_grace_time_seconds }} matrix-pantalaimon >/dev/null 2>&1 || true;
|
|
{{ devture_systemd_docker_base_host_command_docker }} rm -f matrix-pantalaimon >/dev/null 2>&1 || true;
|
|
if {{ devture_systemd_docker_base_host_command_docker }} container inspect matrix-pantalaimon >/dev/null 2>&1; then
|
|
i=$((i + 1));
|
|
sleep {{ matrix_pantalaimon_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-pantalaimon" >&2;
|
|
exit 1;
|
|
done;
|
|
echo "Failed to remove stale container matrix-pantalaimon after {{ matrix_pantalaimon_container_cleanup_timeout_seconds }} attempts" >&2;
|
|
exit 1
|
|
|
|
# List of systemd services that matrix-pantalaimon.service depends on
|
|
matrix_pantalaimon_systemd_required_services_list: "{{ matrix_pantalaimon_systemd_required_services_list_default + matrix_pantalaimon_systemd_required_services_list_auto + matrix_pantalaimon_systemd_required_services_list_custom }}"
|
|
matrix_pantalaimon_systemd_required_services_list_default: "{{ [devture_systemd_docker_base_docker_service_name] if devture_systemd_docker_base_docker_service_name else [] }}"
|
|
matrix_pantalaimon_systemd_required_services_list_auto: []
|
|
matrix_pantalaimon_systemd_required_services_list_custom: []
|
|
|
|
# List of systemd services that matrix-pantalaimon.service wants
|
|
matrix_pantalaimon_systemd_wanted_services_list: "{{ matrix_pantalaimon_systemd_wanted_services_list_default + matrix_pantalaimon_systemd_wanted_services_list_auto + matrix_pantalaimon_systemd_wanted_services_list_custom }}"
|
|
matrix_pantalaimon_systemd_wanted_services_list_default: []
|
|
matrix_pantalaimon_systemd_wanted_services_list_auto: []
|
|
matrix_pantalaimon_systemd_wanted_services_list_custom: []
|
|
|
|
# Valid values: Error, Warning, Info, Debug
|
|
matrix_pantalaimon_log_level: Warning
|
|
|
|
# Base URL where matrix-pantalaimon can reach your homeserver C-S API.
|
|
# If the homeserver runs on the same machine, you may need to add its service to `matrix_pantalaimon_systemd_required_services_list`.
|
|
matrix_pantalaimon_homeserver_url: ""
|
|
|
|
# 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
|
|
# completely replace this variable with your own template.
|
|
matrix_pantalaimon_configuration: "{{ lookup('template', 'templates/pantalaimon.conf.j2') }}"
|
|
|
|
# matrix_pantalaimon_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_pantalaimon_restart_necessary: false
|