Files
matrix-docker-ansible-deploy/roles/custom/matrix-cactus-comments-client/defaults/main.yml
T
Slavi PantaleevandClaude Opus 5.5 bff3f54d53 Harden pre-start container cleanup against name-release races
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>
2026-10-16 19:04:04 +03:00

148 lines
9.5 KiB
YAML

# SPDX-FileCopyrightText: 2024 - 2025 Slavi Pantaleev
# SPDX-FileCopyrightText: 2024 Suguru Hirahara
#
# SPDX-License-Identifier: AGPL-3.0-or-later
---
# Cactus Comments is a federated comment system built on Matrix.
# This role installs the client assets (JS, CSS files).
# Project source code URL: https://gitlab.com/cactus-comments/cactus-client
matrix_cactus_comments_client_enabled: true
matrix_cactus_comments_client_hostname: ''
matrix_cactus_comments_client_path_prefix: /cactus-comments
matrix_cactus_comments_client_base_path: "{{ matrix_base_data_path }}/cactus-comments-client"
matrix_cactus_comments_client_public_path: "{{ matrix_cactus_comments_client_base_path }}/public"
matrix_cactus_comments_client_public_path_file_permissions: "0644"
# renovate: datasource=docker depName=joseluisq/static-web-server
matrix_cactus_comments_client_version: 2.44.1
matrix_cactus_comments_client_container_image: "{{ matrix_cactus_comments_client_container_image_registry_prefix }}joseluisq/static-web-server:{{ matrix_cactus_comments_client_container_image_tag }}"
matrix_cactus_comments_client_container_image_registry_prefix: "{{ matrix_cactus_comments_client_container_image_registry_prefix_upstream }}"
matrix_cactus_comments_client_container_image_registry_prefix_upstream: "{{ matrix_cactus_comments_client_container_image_registry_prefix_upstream_default }}"
matrix_cactus_comments_client_container_image_registry_prefix_upstream_default: docker.io/
matrix_cactus_comments_client_container_image_tag: "{{ 'latest' if matrix_cactus_comments_client_version == 'latest' else (matrix_cactus_comments_client_version + '-alpine') }}"
matrix_cactus_comments_client_container_network: ""
matrix_cactus_comments_client_container_additional_networks: "{{ matrix_cactus_comments_client_container_additional_networks_auto + matrix_cactus_comments_client_container_additional_networks_custom }}"
matrix_cactus_comments_client_container_additional_networks_auto: []
matrix_cactus_comments_client_container_additional_networks_custom: []
# Controls whether the matrix-cactus-comments-client container exposes its HTTP port (tcp/8080 in the container).
#
# Takes an "<ip>:<port>" or "<port>" value (e.g. "127.0.0.1:8080"), or empty string to not expose.
matrix_cactus_comments_client_container_http_host_bind_port: ''
# matrix_cactus_comments_client_container_labels_traefik_enabled controls whether labels to assist a Traefik reverse-proxy will be attached to the container.
# See `../templates/labels.j2` for details.
#
# To inject your own other container labels, see `matrix_cactus_comments_client_container_labels_additional_labels`.
matrix_cactus_comments_client_container_labels_traefik_enabled: true
matrix_cactus_comments_client_container_labels_traefik_docker_network: "{{ matrix_cactus_comments_client_container_network }}"
matrix_cactus_comments_client_container_labels_traefik_entrypoints: web-secure
matrix_cactus_comments_client_container_labels_traefik_tls_certResolver: default # noqa var-naming
# Controls whether labels will be added that serve the /public directory.
matrix_cactus_comments_client_container_labels_public_enabled: true
matrix_cactus_comments_client_container_labels_public_traefik_hostname: "{{ matrix_cactus_comments_client_hostname }}"
matrix_cactus_comments_client_container_labels_public_traefik_path_prefix: "{{ matrix_cactus_comments_client_path_prefix }}"
matrix_cactus_comments_client_container_labels_public_traefik_rule: "Host(`{{ matrix_cactus_comments_client_container_labels_public_traefik_hostname }}`){% if matrix_cactus_comments_client_container_labels_public_traefik_path_prefix != '/' %} && PathPrefix(`{{ matrix_cactus_comments_client_container_labels_public_traefik_path_prefix }}`){% endif %}"
matrix_cactus_comments_client_container_labels_public_traefik_priority: 0
matrix_cactus_comments_client_container_labels_public_traefik_entrypoints: "{{ matrix_cactus_comments_client_container_labels_traefik_entrypoints }}"
matrix_cactus_comments_client_container_labels_public_traefik_tls: "{{ matrix_cactus_comments_client_container_labels_public_traefik_entrypoints != 'web' }}"
matrix_cactus_comments_client_container_labels_public_traefik_tls_certResolver: "{{ matrix_cactus_comments_client_container_labels_traefik_tls_certResolver }}" # noqa var-naming
# matrix_cactus_comments_client_container_labels_additional_labels contains a multiline string with additional labels to add to the container label file.
# See `../templates/labels.j2` for details.
#
# Example:
# matrix_cactus_comments_client_container_labels_additional_labels: |
# my.label=1
# another.label="here"
matrix_cactus_comments_client_container_labels_additional_labels: ''
# A list of extra arguments to pass to the container
matrix_cactus_comments_client_container_extra_arguments: []
# Controls how long the pre-start cleanup should wait for stale container-name release
# before failing startup explicitly.
matrix_cactus_comments_client_container_cleanup_timeout_seconds: "{{ devture_systemd_docker_base_container_cleanup_timeout_seconds }}"
# Controls the delay between pre-start cleanup retries.
matrix_cactus_comments_client_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_cactus_comments_client_container_cleanup_command: |
i=0;
while [ "$i" -lt {{ matrix_cactus_comments_client_container_cleanup_timeout_seconds }} ]; do
{{ devture_systemd_docker_base_host_command_docker }} stop -t {{ devture_systemd_docker_base_container_stop_grace_time_seconds }} matrix-cactus-comments-client >/dev/null 2>&1 || true;
{{ devture_systemd_docker_base_host_command_docker }} rm -f matrix-cactus-comments-client >/dev/null 2>&1 || true;
if {{ devture_systemd_docker_base_host_command_docker }} container inspect matrix-cactus-comments-client >/dev/null 2>&1; then
i=$((i + 1));
sleep {{ matrix_cactus_comments_client_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-cactus-comments-client" >&2;
exit 1;
done;
echo "Failed to remove stale container matrix-cactus-comments-client after {{ matrix_cactus_comments_client_container_cleanup_timeout_seconds }} attempts" >&2;
exit 1
# Controls the SERVER_PORT environment variable.
# See: https://static-web-server.net/configuration/environment-variables/
matrix_cactus_comments_client_environment_variable_server_port: 8080
# Controls the SERVER_LOG_LEVEL environment variable.
# See: https://static-web-server.net/configuration/environment-variables/
# Valid values: error, warn, info, debug, trace
matrix_cactus_comments_client_environment_variable_server_log_level: error
# Controls the SERVER_LOG_REMOTE_ADDRESS environment variable.
# See: https://static-web-server.net/configuration/environment-variables/
matrix_cactus_comments_client_environment_variable_server_log_remote_address: false
# Controls the SERVER_CONFIG_FILE environment variable.
# See: https://static-web-server.net/configuration/environment-variables/
matrix_cactus_comments_client_environment_variable_server_config_file: /config/config.toml
# Additional environment variables.
matrix_cactus_comments_client_environment_variables_additional_variables: ''
# The released & compiled client is uploaded to a URL that changes per commit. Therefore it is necessary to check the
# available versions and adjust the url manually.
# For available versions, see: https://gitlab.com/cactus-comments/cactus-client/-/releases
# Also see: `matrix_cactus_comments_client_local_dir`
matrix_cactus_comments_client_webclient_js_url: "https://gateway.pinata.cloud/ipfs/QmSiWN27KZZ1XE32jKwifBnS3nWTUcFGNArKzur2nmDgoL/v0.13.0/cactus.js"
matrix_cactus_comments_client_webclient_css_url: "https://gateway.pinata.cloud/ipfs/QmSiWN27KZZ1XE32jKwifBnS3nWTUcFGNArKzur2nmDgoL/v0.13.0/style.css"
# matrix_cactus_comments_client_local_dir specifies a local directory (on the Ansible controller, not on the remote server) with cactus-client files to use.
# This is an alternative to `matrix_cactus_comments_client_client_version`, to be used when you'd like to
# provide the files locally / manually.
matrix_cactus_comments_client_local_dir: ''
# List of systemd services that matrix-cactus-comments-client.service depends on
matrix_cactus_comments_client_systemd_required_services_list: "{{ [devture_systemd_docker_base_docker_service_name] if devture_systemd_docker_base_docker_service_name else [] }}"
# List of systemd services that matrix-cactus-comments-client.service wants
matrix_cactus_comments_client_systemd_wanted_services_list: "{{ matrix_cactus_comments_client_systemd_wanted_services_list_auto + matrix_cactus_comments_client_systemd_wanted_services_list_custom }}"
matrix_cactus_comments_client_systemd_wanted_services_list_auto: []
matrix_cactus_comments_client_systemd_wanted_services_list_custom: []
# matrix_cactus_comments_client_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_cactus_comments_client_restart_necessary: false