mirror of
https://github.com/spantaleev/matrix-docker-ansible-deploy.git
synced 2026-10-21 05:44:16 +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>
134 lines
7.6 KiB
YAML
134 lines
7.6 KiB
YAML
# SPDX-FileCopyrightText: 2026 MDAD project contributors
|
|
#
|
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
---
|
|
# Project source code URL: https://github.com/commetchat/commet
|
|
|
|
matrix_client_commet_enabled: true
|
|
|
|
# The git branch, tag, or SHA to build from
|
|
matrix_client_commet_version: "main"
|
|
|
|
# The scheme used for serving Commet.
|
|
matrix_client_commet_scheme: https
|
|
|
|
# The hostname at which Commet is served (e.g. commet.example.com)
|
|
matrix_client_commet_hostname: ""
|
|
|
|
# The path at which Commet is exposed.
|
|
# This value must either be `/` or not end with a slash (e.g. `/commet`).
|
|
matrix_client_commet_path_prefix: /
|
|
|
|
matrix_client_commet_base_path: "{{ matrix_base_data_path }}/client-commet"
|
|
matrix_client_commet_container_src_path: "{{ matrix_client_commet_base_path }}/container-src"
|
|
matrix_client_commet_config_path: "{{ matrix_client_commet_base_path }}/config"
|
|
|
|
# Set to false to pull a pre-built image from a registry instead of building on the server.
|
|
matrix_client_commet_container_image_self_build: true
|
|
|
|
# Self-build settings (used when matrix_client_commet_container_image_self_build: true)
|
|
matrix_client_commet_container_image_self_build_repo: "https://github.com/commetchat/commet.git"
|
|
# Populated automatically after git clone in setup_install.yml
|
|
matrix_client_commet_container_image_self_build_git_hash: ""
|
|
matrix_client_commet_container_image_self_build_version_tag: "{{ matrix_client_commet_version }}"
|
|
matrix_client_commet_container_image: "localhost/matrix-client-commet:{{ matrix_client_commet_version }}"
|
|
|
|
# The in-container port nginx listens on
|
|
matrix_client_commet_container_port: 8080
|
|
|
|
# Optionally expose the container port on the host.
|
|
# Takes an "<ip>:<port>" or "<port>" value (e.g. "127.0.0.1:8765"), or empty string to not expose.
|
|
matrix_client_commet_container_http_host_bind_port: ""
|
|
|
|
# The base container network
|
|
matrix_client_commet_container_network: ""
|
|
|
|
# Additional container networks the container is connected to.
|
|
# The role does not create these networks, so make sure they already exist.
|
|
matrix_client_commet_container_additional_networks: []
|
|
|
|
# Runtime configuration — mounted into the container, not baked into the image
|
|
matrix_client_commet_default_homeserver: "matrix.org"
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Traefik labels
|
|
# ---------------------------------------------------------------------------
|
|
matrix_client_commet_container_labels_traefik_enabled: true
|
|
matrix_client_commet_container_labels_traefik_docker_network: "{{ matrix_client_commet_container_network }}"
|
|
matrix_client_commet_container_labels_traefik_hostname: "{{ matrix_client_commet_hostname }}"
|
|
# The path prefix must either be `/` or not end with a slash (e.g. `/commet`).
|
|
matrix_client_commet_container_labels_traefik_path_prefix: "{{ matrix_client_commet_path_prefix }}"
|
|
matrix_client_commet_container_labels_traefik_rule: "Host(`{{ matrix_client_commet_container_labels_traefik_hostname }}`){% if matrix_client_commet_container_labels_traefik_path_prefix != '/' %} && PathPrefix(`{{ matrix_client_commet_container_labels_traefik_path_prefix }}`){% endif %}"
|
|
matrix_client_commet_container_labels_traefik_priority: 0
|
|
matrix_client_commet_container_labels_traefik_entrypoints: web-secure
|
|
matrix_client_commet_container_labels_traefik_tls: "{{ matrix_client_commet_container_labels_traefik_entrypoints != 'web' }}"
|
|
matrix_client_commet_container_labels_traefik_tls_certResolver: default # noqa var-naming
|
|
|
|
# Controls whether a compression middleware will be injected into the middlewares list.
|
|
matrix_client_commet_container_labels_traefik_compression_middleware_enabled: false
|
|
matrix_client_commet_container_labels_traefik_compression_middleware_name: ""
|
|
|
|
# Additional response headers (auto-built from security header variables below)
|
|
matrix_client_commet_container_labels_traefik_additional_response_headers: "{{ matrix_client_commet_container_labels_traefik_additional_response_headers_auto | combine(matrix_client_commet_container_labels_traefik_additional_response_headers_custom) }}"
|
|
matrix_client_commet_container_labels_traefik_additional_response_headers_auto: |
|
|
{{
|
|
{}
|
|
| combine({'X-XSS-Protection': matrix_client_commet_http_header_xss_protection} if matrix_client_commet_http_header_xss_protection else {})
|
|
| combine({'X-Content-Type-Options': matrix_client_commet_http_header_content_type_options} if matrix_client_commet_http_header_content_type_options else {})
|
|
| combine({'Content-Security-Policy': matrix_client_commet_http_header_content_security_policy} if matrix_client_commet_http_header_content_security_policy else {})
|
|
| combine({'Strict-Transport-Security': matrix_client_commet_http_header_strict_transport_security} if matrix_client_commet_http_header_strict_transport_security and matrix_client_commet_container_labels_traefik_tls else {})
|
|
}}
|
|
matrix_client_commet_container_labels_traefik_additional_response_headers_custom: {}
|
|
|
|
# Additional container labels (multiline string)
|
|
matrix_client_commet_container_labels_additional_labels: ""
|
|
|
|
# Extra arguments to pass to docker create
|
|
matrix_client_commet_container_extra_arguments: []
|
|
|
|
# Controls how long the pre-start cleanup should wait for stale container-name release
|
|
# before failing startup explicitly.
|
|
matrix_client_commet_container_cleanup_timeout_seconds: "{{ devture_systemd_docker_base_container_cleanup_timeout_seconds }}"
|
|
|
|
# Controls the delay between pre-start cleanup retries.
|
|
matrix_client_commet_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_client_commet_container_cleanup_command: |
|
|
i=0;
|
|
while [ "$i" -lt {{ matrix_client_commet_container_cleanup_timeout_seconds }} ]; do
|
|
{{ devture_systemd_docker_base_host_command_docker }} stop -t {{ devture_systemd_docker_base_container_stop_grace_time_seconds }} matrix-client-commet >/dev/null 2>&1 || true;
|
|
{{ devture_systemd_docker_base_host_command_docker }} rm -f matrix-client-commet >/dev/null 2>&1 || true;
|
|
if {{ devture_systemd_docker_base_host_command_docker }} container inspect matrix-client-commet >/dev/null 2>&1; then
|
|
i=$((i + 1));
|
|
sleep {{ matrix_client_commet_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-client-commet" >&2;
|
|
exit 1;
|
|
done;
|
|
echo "Failed to remove stale container matrix-client-commet after {{ matrix_client_commet_container_cleanup_timeout_seconds }} attempts" >&2;
|
|
exit 1
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# HTTP security headers
|
|
# ---------------------------------------------------------------------------
|
|
matrix_client_commet_http_header_xss_protection: "1; mode=block"
|
|
matrix_client_commet_http_header_content_type_options: nosniff
|
|
matrix_client_commet_http_header_content_security_policy: "frame-ancestors 'self'"
|
|
matrix_client_commet_http_header_strict_transport_security: "max-age=31536000; includeSubDomains"
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Systemd
|
|
# ---------------------------------------------------------------------------
|
|
matrix_client_commet_systemd_required_services_list: "{{ [devture_systemd_docker_base_docker_service_name] if devture_systemd_docker_base_docker_service_name else [] }}"
|
|
|
|
# matrix_client_commet_restart_necessary is automatically set during installation
|
|
# to signal whether the service should be restarted after setup.
|
|
matrix_client_commet_restart_necessary: false
|