From 4aa707ae88f776cf227bd0ecd76dcf637218212d Mon Sep 17 00:00:00 2001 From: Suguru Hirahara Date: Thu, 12 Feb 2026 21:26:59 +0900 Subject: [PATCH] Remove `matrix-client-hydrogen` in favor of ansible-role-hydrogen Signed-off-by: Suguru Hirahara --- .../matrix-client-hydrogen/defaults/main.yml | 193 ------------------ .../matrix-client-hydrogen/tasks/main.yml | 32 --- .../tasks/self_check.yml | 30 --- .../tasks/setup_install.yml | 101 --------- .../tasks/setup_uninstall.yml | 31 --- .../tasks/validate_config.yml | 45 ---- .../templates/config.json.j2 | 12 -- .../templates/config.json.j2.license | 7 - .../templates/labels.j2 | 56 ----- .../templates/nginx.conf.j2 | 70 ------- .../templates/nginx.conf.j2.license | 4 - .../systemd/matrix-client-hydrogen.service.j2 | 50 ----- .../matrix-client-hydrogen.service.j2.license | 5 - 13 files changed, 636 deletions(-) delete mode 100644 roles/custom/matrix-client-hydrogen/defaults/main.yml delete mode 100644 roles/custom/matrix-client-hydrogen/tasks/main.yml delete mode 100644 roles/custom/matrix-client-hydrogen/tasks/self_check.yml delete mode 100644 roles/custom/matrix-client-hydrogen/tasks/setup_install.yml delete mode 100644 roles/custom/matrix-client-hydrogen/tasks/setup_uninstall.yml delete mode 100644 roles/custom/matrix-client-hydrogen/tasks/validate_config.yml delete mode 100644 roles/custom/matrix-client-hydrogen/templates/config.json.j2 delete mode 100644 roles/custom/matrix-client-hydrogen/templates/config.json.j2.license delete mode 100644 roles/custom/matrix-client-hydrogen/templates/labels.j2 delete mode 100644 roles/custom/matrix-client-hydrogen/templates/nginx.conf.j2 delete mode 100644 roles/custom/matrix-client-hydrogen/templates/nginx.conf.j2.license delete mode 100644 roles/custom/matrix-client-hydrogen/templates/systemd/matrix-client-hydrogen.service.j2 delete mode 100644 roles/custom/matrix-client-hydrogen/templates/systemd/matrix-client-hydrogen.service.j2.license diff --git a/roles/custom/matrix-client-hydrogen/defaults/main.yml b/roles/custom/matrix-client-hydrogen/defaults/main.yml deleted file mode 100644 index 2ecc8c2a1..000000000 --- a/roles/custom/matrix-client-hydrogen/defaults/main.yml +++ /dev/null @@ -1,193 +0,0 @@ -# SPDX-FileCopyrightText: 2021 - 2022 Aaron Raimist -# SPDX-FileCopyrightText: 2021 - 2022 MDAD project contributors -# SPDX-FileCopyrightText: 2021 - 2025 Slavi Pantaleev -# SPDX-FileCopyrightText: 2022 - 2023 Nikita Chernyi -# SPDX-FileCopyrightText: 2022 Marko Weltzer -# SPDX-FileCopyrightText: 2022 Matthew Cengia -# SPDX-FileCopyrightText: 2023 Pierre 'McFly' Marty -# SPDX-FileCopyrightText: 2023 Samuel Meenzen -# -# SPDX-License-Identifier: AGPL-3.0-or-later - ---- -# Project source code URL: https://github.com/element-hq/hydrogen-web - -hydrogen_enabled: true - -hydrogen_container_image_self_build: false -hydrogen_container_image_self_build_repo: "https://github.com/element-hq/hydrogen-web.git" - -# renovate: datasource=docker depName=ghcr.io/element-hq/hydrogen-web -hydrogen_version: v0.5.1 -hydrogen_container_image: "{{ hydrogen_container_image_registry_prefix }}element-hq/hydrogen-web:{{ hydrogen_version }}" -hydrogen_container_image_registry_prefix_upstream_default: ghcr.io/ -hydrogen_container_image_force_pull: "{{ hydrogen_container_image.endswith(':latest') }}" - -hydrogen_base_path: "{{ matrix_base_data_path }}/client-hydrogen" -hydrogen_docker_src_files_path: "{{ hydrogen_base_path }}/docker-src" - -# The base container network -hydrogen_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. -# Use this to expose this container to a reverse proxy, which runs in a different container network. -hydrogen_container_additional_networks: [] - -# Controls whether the container exposes its HTTP port (tcp/8080 in the container). -# -# Takes an ":" or "" value (e.g. "127.0.0.1:8768"), or empty string to not expose. -hydrogen_container_http_host_bind_port: '' - -# hydrogen_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 `hydrogen_container_labels_additional_labels`. -hydrogen_container_labels_traefik_enabled: true -hydrogen_container_labels_traefik_docker_network: "{{ hydrogen_container_network }}" -hydrogen_container_labels_traefik_hostname: "{{ hydrogen_hostname }}" -# The path prefix must either be `/` or not end with a slash (e.g. `/hydrogen`). -hydrogen_container_labels_traefik_path_prefix: "{{ hydrogen_path_prefix }}" -hydrogen_container_labels_traefik_rule: "Host(`{{ hydrogen_container_labels_traefik_hostname }}`){% if hydrogen_container_labels_traefik_path_prefix != '/' %} && PathPrefix(`{{ hydrogen_container_labels_traefik_path_prefix }}`){% endif %}" -hydrogen_container_labels_traefik_priority: 0 -hydrogen_container_labels_traefik_entrypoints: web-secure -hydrogen_container_labels_traefik_tls: "{{ hydrogen_container_labels_traefik_entrypoints != 'web' }}" -hydrogen_container_labels_traefik_tls_certResolver: default # noqa var-naming - -# Controls whether a compression middleware will be injected into the middlewares list. -# This compression middleware is supposed to be defined elsewhere (using labels or a File provider, etc.) and is merely referenced by this router. -hydrogen_container_labels_traefik_compression_middleware_enabled: false -hydrogen_container_labels_traefik_compression_middleware_name: "" - -# Controls which additional headers to attach to all HTTP responses. -# To add your own headers, use `hydrogen_container_labels_traefik_additional_response_headers_custom` -hydrogen_container_labels_traefik_additional_response_headers: "{{ hydrogen_container_labels_traefik_additional_response_headers_auto | combine(hydrogen_container_labels_traefik_additional_response_headers_custom) }}" -hydrogen_container_labels_traefik_additional_response_headers_auto: | - {{ - {} - | combine ({'X-XSS-Protection': hydrogen_http_header_xss_protection} if hydrogen_http_header_xss_protection else {}) - | combine ({'X-Content-Type-Options': hydrogen_http_header_content_type_options} if hydrogen_http_header_content_type_options else {}) - | combine ({'Content-Security-Policy': hydrogen_http_header_content_security_policy} if hydrogen_http_header_content_security_policy else {}) - | combine ({'Permission-Policy': hydrogen_http_header_content_permission_policy} if hydrogen_http_header_content_permission_policy else {}) - | combine ({'Strict-Transport-Security': hydrogen_http_header_strict_transport_security} if hydrogen_http_header_strict_transport_security and hydrogen_container_labels_traefik_tls else {}) - }} -hydrogen_container_labels_traefik_additional_response_headers_custom: {} - -# hydrogen_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: -# hydrogen_container_labels_additional_labels: | -# my.label=1 -# another.label="here" -hydrogen_container_labels_additional_labels: '' - -# A list of extra arguments to pass to the container -hydrogen_container_extra_arguments: [] - -# List of systemd services that hydrogen.service depends on -hydrogen_systemd_required_services_list: "{{ [devture_systemd_docker_base_docker_service_name] if devture_systemd_docker_base_docker_service_name else [] }}" - -# Specifies the value of the `X-XSS-Protection` header -# Stops pages from loading when they detect reflected cross-site scripting (XSS) attacks. -# -# Learn more about it is here: -# - https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-XSS-Protection -# - https://portswigger.net/web-security/cross-site-scripting/reflected -hydrogen_http_header_xss_protection: "1; mode=block" - -# Specifies the value of the `X-Content-Type-Options` header. -# See: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Content-Type-Options -hydrogen_http_header_content_type_options: nosniff - -# Specifies the value of the `Content-Security-Policy` header. -# See: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy -hydrogen_http_header_content_security_policy: frame-ancestors 'self' - -# Specifies the value of the `Permission-Policy` header. -# See: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Permission-Policy -hydrogen_http_header_content_permission_policy: "{{ 'interest-cohort=()' if hydrogen_floc_optout_enabled else '' }}" - -# Specifies the value of the `Strict-Transport-Security` header. -# See: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Strict-Transport-Security -hydrogen_http_header_strict_transport_security: "max-age=31536000; includeSubDomains{{ '; preload' if hydrogen_hsts_preload_enabled else '' }}" - -# Controls whether to send a "Permissions-Policy interest-cohort=();" header along with all responses -# -# Learn more about what it is here: -# - https://www.eff.org/deeplinks/2021/03/googles-floc-terrible-idea -# - https://paramdeo.com/blog/opting-your-website-out-of-googles-floc-network -# - https://amifloced.org/ -# -# Of course, a better solution is to just stop using browsers (like Chrome), which participate in such tracking practices. -# See: `hydrogen_content_permission_policy` -hydrogen_floc_optout_enabled: true - -# Controls if HSTS preloading is enabled -# -# In its strongest and recommended form, the [HSTS policy](https://www.chromium.org/hsts) includes all subdomains, and -# indicates a willingness to be "preloaded" into browsers: -# `Strict-Transport-Security: max-age=31536000; includeSubDomains; preload` -# For more information visit: -# - https://en.wikipedia.org/wiki/HTTP_Strict_Transport_Security -# - https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Strict-Transport-Security -# - https://hstspreload.org/#opt-in -# See: `hydrogen_http_header_strict_transport_security` -hydrogen_hsts_preload_enabled: false - -hydrogen_scheme: https - -# The path at which Hydrogen is exposed. -# This value must either be `/` or not end with a slash (e.g. `/hydrogen`). -hydrogen_path_prefix: / - -# Controls whether the self-check feature should validate SSL certificates. -hydrogen_self_check_validate_certificates: true - -# Controls whether the access log is enabled. -hydrogen_access_log_enabled: true - -# config.json -hydrogen_push: - appId: io.element.hydrogen.web - gatewayUrl: https://matrix.org - applicationServerKey: "BC-gpSdVHEXhvHSHS0AzzWrQoukv2BE7KzpoPO_FfPacqOo3l1pdqz7rSgmB04pZCWaHPz7XRe6fjLaC-WPDopM" -hydrogen_default_hs_url: "" -hydrogen_bugReportEndpointUrl: "https://element.io/bugreports/submit" # noqa var-naming - -# Default Hydrogen 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 `hydrogen_configuration_extension_json`) -# or completely replace this variable with your own template. -# -# The side-effect of this lookup is that Ansible would even parse the JSON for us, returning a dict. -# This is unlike what it does when looking up YAML template files (no automatic parsing there). -hydrogen_configuration_default: "{{ lookup('template', 'templates/config.json.j2', convert_data=False) | from_json }}" - -# Your custom JSON configuration for Hydrogen should go to `hydrogen_configuration_extension_json`. -# This configuration extends the default starting configuration (`hydrogen_configuration_default`). -# -# 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 `hydrogen_configuration_default`. -# -# Example configuration extension follows: -# -# hydrogen_configuration_extension_json: | -# { -# "push": { -# "appId": "io.element.hydrogen.web", -# "gatewayUrl": "https://matrix.org", -# "applicationServerKey": "BC-gpSdVHEXhvHSHS0AzzWrQoukv2BE7KzpoPO_FfPacqOo3l1pdqz7rSgmB04pZCWaHPz7XRe6fjLaC-WPDopM" -# }, -# "defaultHomeServer": "matrix.org" -# } -hydrogen_configuration_extension_json: '{}' - -hydrogen_configuration_extension: "{{ hydrogen_configuration_extension_json | from_json if hydrogen_configuration_extension_json | from_json is mapping else {} }}" - -# Holds the final Hydrogen configuration (a combination of the default and its extension). -# You most likely don't need to touch this variable. Instead, see `hydrogen_configuration_default`. -hydrogen_configuration: "{{ hydrogen_configuration_default | combine(hydrogen_configuration_extension, recursive=True) }}" diff --git a/roles/custom/matrix-client-hydrogen/tasks/main.yml b/roles/custom/matrix-client-hydrogen/tasks/main.yml deleted file mode 100644 index 329d63274..000000000 --- a/roles/custom/matrix-client-hydrogen/tasks/main.yml +++ /dev/null @@ -1,32 +0,0 @@ -# SPDX-FileCopyrightText: 2021 - 2023 Slavi Pantaleev -# SPDX-FileCopyrightText: 2021 Aaron Raimist -# SPDX-FileCopyrightText: 2022 Marko Weltzer -# -# SPDX-License-Identifier: AGPL-3.0-or-later - ---- - -- tags: - - setup-all - - setup-client-hydrogen - - install-all - - install-client-hydrogen - block: - - when: hydrogen_enabled | bool - ansible.builtin.include_tasks: "{{ role_path }}/tasks/validate_config.yml" - - - when: hydrogen_enabled | bool - ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_install.yml" - -- tags: - - setup-all - - setup-client-hydrogen - block: - - when: not hydrogen_enabled | bool - ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" - -- tags: - - self-check - block: - - when: hydrogen_enabled | bool - ansible.builtin.include_tasks: "{{ role_path }}/tasks/self_check.yml" diff --git a/roles/custom/matrix-client-hydrogen/tasks/self_check.yml b/roles/custom/matrix-client-hydrogen/tasks/self_check.yml deleted file mode 100644 index 23cc19d1f..000000000 --- a/roles/custom/matrix-client-hydrogen/tasks/self_check.yml +++ /dev/null @@ -1,30 +0,0 @@ -# SPDX-FileCopyrightText: 2021 - 2022 Aaron Raimist -# SPDX-FileCopyrightText: 2022 - 2024 Slavi Pantaleev -# SPDX-FileCopyrightText: 2022 Marko Weltzer -# -# SPDX-License-Identifier: AGPL-3.0-or-later - ---- - -- ansible.builtin.set_fact: - hydrogen_url_endpoint_public: "{{ hydrogen_scheme }}://{{ hydrogen_hostname }}{{ hydrogen_path_prefix }}/config.json" - -- name: Check Hydrogen - ansible.builtin.uri: - url: "{{ hydrogen_url_endpoint_public }}" - follow_redirects: none - validate_certs: "{{ hydrogen_self_check_validate_certificates }}" - register: hydrogen_self_check_result - check_mode: false - ignore_errors: true - delegate_to: 127.0.0.1 - become: false - -- name: Fail if Hydrogen not working - ansible.builtin.fail: - msg: "Failed checking Hydrogen is up at `{{ hydrogen_hostname }}` (checked endpoint: `{{ hydrogen_url_endpoint_public }}`). Is Hydrogen running? Is port 443 open in your firewall? Full error: {{ hydrogen_self_check_result }}" - when: "hydrogen_self_check_result.failed or 'json' not in hydrogen_self_check_result" - -- name: Report working Hydrogen - ansible.builtin.debug: - msg: "Hydrogen at `{{ hydrogen_hostname }}` is working (checked endpoint: `{{ hydrogen_url_endpoint_public }}`)" diff --git a/roles/custom/matrix-client-hydrogen/tasks/setup_install.yml b/roles/custom/matrix-client-hydrogen/tasks/setup_install.yml deleted file mode 100644 index ae5e72e51..000000000 --- a/roles/custom/matrix-client-hydrogen/tasks/setup_install.yml +++ /dev/null @@ -1,101 +0,0 @@ -# SPDX-FileCopyrightText: 2021 - 2022 Aaron Raimist -# SPDX-FileCopyrightText: 2021 - 2024 Slavi Pantaleev -# SPDX-FileCopyrightText: 2022 Marko Weltzer -# SPDX-FileCopyrightText: 2022 Matthew Cengia -# SPDX-FileCopyrightText: 2022 Nikita Chernyi -# SPDX-FileCopyrightText: 2022 Sebastian Gumprich -# SPDX-FileCopyrightText: 2023 Julian Foad -# SPDX-FileCopyrightText: 2024 David Mehren -# -# SPDX-License-Identifier: AGPL-3.0-or-later - ---- - -- name: Ensure Hydrogen paths exists - ansible.builtin.file: - path: "{{ item.path }}" - state: directory - mode: 0750 - owner: "{{ matrix_user_name }}" - group: "{{ matrix_group_name }}" - with_items: - - {path: "{{ hydrogen_base_path }}", when: true} - - {path: "{{ hydrogen_docker_src_files_path }}", when: "{{ hydrogen_container_image_self_build }}"} - when: "item.when | bool" - -- when: "hydrogen_container_image_self_build | bool" - block: - - name: Ensure Hydrogen repository is present on self-build - ansible.builtin.git: - repo: "{{ hydrogen_container_image_self_build_repo }}" - dest: "{{ hydrogen_docker_src_files_path }}" - version: "{{ hydrogen_container_image.split(':')[1] }}" - force: "yes" - become: true - become_user: "{{ matrix_user_name }}" - register: hydrogen_git_pull_results - - - name: Check if Hydrogen Docker image exists - ansible.builtin.command: "{{ devture_systemd_docker_base_host_command_docker }} images --quiet --filter 'reference={{ hydrogen_container_image }}'" - register: hydrogen_container_image_check_result - changed_when: false - - # Invoking the `docker build` command here, instead of calling the `docker_image` Ansible module, - # because the latter does not support BuildKit. - # See: https://github.com/ansible-collections/community.general/issues/514 - - name: Ensure Hydrogen Docker image is built - ansible.builtin.shell: - chdir: "{{ hydrogen_docker_src_files_path }}" - cmd: | - {{ devture_systemd_docker_base_host_command_docker }} build \ - -t "{{ hydrogen_container_image }}" \ - -f Dockerfile \ - . - environment: - DOCKER_BUILDKIT: 1 - changed_when: true - when: "hydrogen_git_pull_results.changed | bool or hydrogen_container_image_check_result.stdout == ''" - -- name: Ensure Hydrogen Docker image is pulled - community.docker.docker_image: - name: "{{ hydrogen_container_image }}" - source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}" - force_source: "{{ hydrogen_container_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}" - force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else hydrogen_container_image_force_pull }}" - when: "not hydrogen_container_image_self_build | bool" - register: result - retries: "{{ devture_playbook_help_container_retries_count }}" - delay: "{{ devture_playbook_help_container_retries_delay }}" - until: result is not failed - -- name: Ensure Hydrogen configuration installed - ansible.builtin.copy: - content: "{{ hydrogen_configuration | to_nice_json }}" - dest: "{{ hydrogen_base_path }}/config.json" - mode: 0644 - owner: "{{ matrix_user_name }}" - group: "{{ matrix_group_name }}" - -- name: Ensure Hydrogen additional config files installed - ansible.builtin.template: - src: "{{ item.src }}" - dest: "{{ hydrogen_base_path }}/{{ item.name }}" - mode: 0644 - owner: "{{ matrix_user_name }}" - group: "{{ matrix_group_name }}" - with_items: - - {src: "{{ role_path }}/templates/nginx.conf.j2", name: "nginx.conf"} - - {src: "{{ role_path }}/templates/labels.j2", name: "labels"} - -- name: Ensure Hydrogen container network is created - community.general.docker_network: - enable_ipv6: "{{ devture_systemd_docker_base_ipv6_enabled }}" - name: "{{ hydrogen_container_network }}" - driver: bridge - driver_options: "{{ devture_systemd_docker_base_container_networks_driver_options }}" - -- name: Ensure hydrogen.service installed - ansible.builtin.template: - src: "{{ role_path }}/templates/systemd/hydrogen.service.j2" - dest: "{{ devture_systemd_docker_base_systemd_path }}/hydrogen.service" - mode: 0644 diff --git a/roles/custom/matrix-client-hydrogen/tasks/setup_uninstall.yml b/roles/custom/matrix-client-hydrogen/tasks/setup_uninstall.yml deleted file mode 100644 index 9a45f0fa6..000000000 --- a/roles/custom/matrix-client-hydrogen/tasks/setup_uninstall.yml +++ /dev/null @@ -1,31 +0,0 @@ -# SPDX-FileCopyrightText: 2021 - 2022 Slavi Pantaleev -# SPDX-FileCopyrightText: 2022 Marko Weltzer -# SPDX-FileCopyrightText: 2022 Sebastian Gumprich -# -# SPDX-License-Identifier: AGPL-3.0-or-later - ---- - -- name: Check existence of hydrogen.service - ansible.builtin.stat: - path: "{{ devture_systemd_docker_base_systemd_path }}/hydrogen.service" - register: hydrogen_service_stat - -- when: hydrogen_service_stat.stat.exists | bool - block: - - name: Ensure hydrogen is stopped - ansible.builtin.service: - name: hydrogen - state: stopped - enabled: false - daemon_reload: true - - - name: Ensure hydrogen.service doesn't exist - ansible.builtin.file: - path: "{{ devture_systemd_docker_base_systemd_path }}/hydrogen.service" - state: absent - - - name: Ensure Hydrogen paths doesn't exist - ansible.builtin.file: - path: "{{ hydrogen_base_path }}" - state: absent diff --git a/roles/custom/matrix-client-hydrogen/tasks/validate_config.yml b/roles/custom/matrix-client-hydrogen/tasks/validate_config.yml deleted file mode 100644 index f78b504e6..000000000 --- a/roles/custom/matrix-client-hydrogen/tasks/validate_config.yml +++ /dev/null @@ -1,45 +0,0 @@ -# SPDX-FileCopyrightText: 2021 Aaron Raimist -# SPDX-FileCopyrightText: 2022 - 2025 Slavi Pantaleev -# SPDX-FileCopyrightText: 2024 Suguru Hirahara -# -# SPDX-License-Identifier: AGPL-3.0-or-later - ---- - -- name: Fail if required Hydrogen settings not defined - ansible.builtin.fail: - msg: > - You need to define a required configuration setting (`{{ item }}`) to use Hydrogen. - when: "item.when | bool and lookup('vars', item.name, default='') | string | length == 0" - with_items: - - {'name': 'hydrogen_default_hs_url', when: "{{ hydrogen_container_image_self_build }}"} - - {'name': 'hydrogen_container_network', when: true} - - {'name': 'hydrogen_container_labels_traefik_compression_middleware_name', when: "{{ hydrogen_container_labels_traefik_compression_middleware_enabled }}"} - -- name: (Deprecation) Catch and report renamed Hydrogen variables - ansible.builtin.fail: - msg: >- - The variable `{{ item.old }}` is deprecated. Please use `{{ item.new }}` instead. - when: "lookup('ansible.builtin.varnames', ('^' + item.old + '$'), wantlist=True) | length > 0" - with_items: - - {'old': 'hydrogen_container_image_name_prefix', 'new': 'hydrogen_container_image_registry_prefix'} - -- when: hydrogen_container_labels_traefik_enabled | bool - block: - - name: Fail if required hydrogen Traefik settings not defined - ansible.builtin.fail: - msg: >- - You need to define a required configuration setting (`{{ item }}`). - when: "lookup('vars', item, default='') == ''" - with_items: - - hydrogen_container_labels_traefik_hostname - - hydrogen_container_labels_traefik_path_prefix - - # We ensure it doesn't end with a slash, because we handle both (slash and no-slash). - # Knowing that `hydrogen_container_labels_traefik_path_prefix` does not end with a slash - # ensures we know how to set these routes up without having to do "does it end with a slash" checks elsewhere. - - name: Fail if hydrogen_container_labels_traefik_path_prefix ends with a slash - ansible.builtin.fail: - msg: >- - hydrogen_container_labels_traefik_path_prefix (`{{ hydrogen_container_labels_traefik_path_prefix }}`) must either be `/` or not end with a slash (e.g. `/hydrogen`). - when: "hydrogen_container_labels_traefik_path_prefix != '/' and hydrogen_container_labels_traefik_path_prefix[-1] == '/'" diff --git a/roles/custom/matrix-client-hydrogen/templates/config.json.j2 b/roles/custom/matrix-client-hydrogen/templates/config.json.j2 deleted file mode 100644 index c2487c785..000000000 --- a/roles/custom/matrix-client-hydrogen/templates/config.json.j2 +++ /dev/null @@ -1,12 +0,0 @@ -{ - "push": {{ hydrogen_push | to_json }}, - "defaultHomeServer": {{ hydrogen_default_hs_url | string | to_json }}, - "bugReportEndpointUrl": {{ hydrogen_bugReportEndpointUrl | to_json }}, - "themeManifests": [ - "{{ '' if hydrogen_path_prefix == '/' else hydrogen_path_prefix }}/assets/theme-element.json" - ], - "defaultTheme": { - "light": "element-light", - "dark": "element-dark" - } -} diff --git a/roles/custom/matrix-client-hydrogen/templates/config.json.j2.license b/roles/custom/matrix-client-hydrogen/templates/config.json.j2.license deleted file mode 100644 index a4ca23eb3..000000000 --- a/roles/custom/matrix-client-hydrogen/templates/config.json.j2.license +++ /dev/null @@ -1,7 +0,0 @@ -SPDX-FileCopyrightText: 2021 - 2022 Aaron Raimist -SPDX-FileCopyrightText: 2022 - 2023 Slavi Pantaleev -SPDX-FileCopyrightText: 2022 Matthew Cengia -SPDX-FileCopyrightText: 2022 Nikita Chernyi -SPDX-FileCopyrightText: 2023 Sergio Durigan Junior - -SPDX-License-Identifier: AGPL-3.0-or-later diff --git a/roles/custom/matrix-client-hydrogen/templates/labels.j2 b/roles/custom/matrix-client-hydrogen/templates/labels.j2 deleted file mode 100644 index 2676a2bed..000000000 --- a/roles/custom/matrix-client-hydrogen/templates/labels.j2 +++ /dev/null @@ -1,56 +0,0 @@ -{# -SPDX-FileCopyrightText: 2023 - 2024 Slavi Pantaleev - -SPDX-License-Identifier: AGPL-3.0-or-later -#} - -{% if hydrogen_container_labels_traefik_enabled %} -traefik.enable=true - -{% if hydrogen_container_labels_traefik_docker_network %} -traefik.docker.network={{ hydrogen_container_labels_traefik_docker_network }} -{% endif %} - -traefik.http.services.hydrogen.loadbalancer.server.port=8080 - -{% set middlewares = [] %} - -{% if hydrogen_container_labels_traefik_compression_middleware_enabled %} -{% set middlewares = middlewares + [hydrogen_container_labels_traefik_compression_middleware_name] %} -{% endif %} - -{% if hydrogen_container_labels_traefik_path_prefix != '/' %} -traefik.http.middlewares.hydrogen-slashless-redirect.redirectregex.regex=({{ hydrogen_container_labels_traefik_path_prefix | quote }})$ -traefik.http.middlewares.hydrogen-slashless-redirect.redirectregex.replacement=${1}/ -{% set middlewares = middlewares + ['hydrogen-slashless-redirect'] %} -{% endif %} - -{% if hydrogen_container_labels_traefik_path_prefix != '/' %} -traefik.http.middlewares.hydrogen-strip-prefix.stripprefix.prefixes={{ hydrogen_container_labels_traefik_path_prefix }} -{% set middlewares = middlewares + ['hydrogen-strip-prefix'] %} -{% endif %} - -{% if hydrogen_container_labels_traefik_additional_response_headers.keys() | length > 0 %} -{% for name, value in hydrogen_container_labels_traefik_additional_response_headers.items() %} -traefik.http.middlewares.hydrogen-add-headers.headers.customresponseheaders.{{ name }}={{ value }} -{% endfor %} -{% set middlewares = middlewares + ['hydrogen-add-headers'] %} -{% endif %} - -traefik.http.routers.hydrogen.rule={{ hydrogen_container_labels_traefik_rule }} -{% if hydrogen_container_labels_traefik_priority | int > 0 %} -traefik.http.routers.hydrogen.priority={{ hydrogen_container_labels_traefik_priority }} -{% endif %} -traefik.http.routers.hydrogen.service=hydrogen -{% if middlewares | length > 0 %} -traefik.http.routers.hydrogen.middlewares={{ middlewares | join(',') }} -{% endif %} -traefik.http.routers.hydrogen.entrypoints={{ hydrogen_container_labels_traefik_entrypoints }} -traefik.http.routers.hydrogen.tls={{ hydrogen_container_labels_traefik_tls | to_json }} -{% if hydrogen_container_labels_traefik_tls %} -traefik.http.routers.hydrogen.tls.certResolver={{ hydrogen_container_labels_traefik_tls_certResolver }} -{% endif %} - -{% endif %} - -{{ hydrogen_container_labels_additional_labels }} diff --git a/roles/custom/matrix-client-hydrogen/templates/nginx.conf.j2 b/roles/custom/matrix-client-hydrogen/templates/nginx.conf.j2 deleted file mode 100644 index a886326bb..000000000 --- a/roles/custom/matrix-client-hydrogen/templates/nginx.conf.j2 +++ /dev/null @@ -1,70 +0,0 @@ -#jinja2: lstrip_blocks: True -# This is a custom nginx configuration file that we use in the container (instead of the default one), -# because it allows us to run nginx with a non-root user. -# -# For this to work, the default vhost file (`/etc/nginx/conf.d/default.conf`) also needs to be removed. -# (mounting `/dev/null` over `/etc/nginx/conf.d/default.conf` works well) -# -# The following changes have been done compared to a default nginx configuration file: -# - default server port is changed (80 -> 8080), so that a non-root user can bind it -# - various temp paths are changed to `/tmp`, so that a non-root user can write to them -# - the `user` directive was removed, as we don't want nginx to switch users - -worker_processes 1; - -error_log /var/log/nginx/error.log warn; -pid /tmp/nginx.pid; - - -events { - worker_connections 1024; -} - - -http { - proxy_temp_path /tmp/proxy_temp; - client_body_temp_path /tmp/client_temp; - fastcgi_temp_path /tmp/fastcgi_temp; - uwsgi_temp_path /tmp/uwsgi_temp; - scgi_temp_path /tmp/scgi_temp; - - include /etc/nginx/mime.types; - default_type application/octet-stream; - - log_format main '$remote_addr - $remote_user [$time_local] "$request" ' - '$status $body_bytes_sent "$http_referer" ' - '"$http_user_agent" "$http_x_forwarded_for"'; - - {% if hydrogen_access_log_enabled %} - access_log /var/log/nginx/access.log main; - {% else %} - access_log off; - {% endif %} - - sendfile on; - #tcp_nopush on; - - keepalive_timeout 65; - - #gzip on; - - server { - listen 8080; - server_name localhost; - - root /usr/share/nginx/html; - - location / { - index index.html index.htm; - } - - location ~* ^/(config(.+)?\.json$|(.+)\.html$|i18n) { - expires -1; - } - - error_page 500 502 503 504 /50x.html; - location = /50x.html { - root /usr/share/nginx/html; - } - } -} diff --git a/roles/custom/matrix-client-hydrogen/templates/nginx.conf.j2.license b/roles/custom/matrix-client-hydrogen/templates/nginx.conf.j2.license deleted file mode 100644 index c69a90227..000000000 --- a/roles/custom/matrix-client-hydrogen/templates/nginx.conf.j2.license +++ /dev/null @@ -1,4 +0,0 @@ -SPDX-FileCopyrightText: 2021 Aaron Raimist -SPDX-FileCopyrightText: 2022 Slavi Pantaleev - -SPDX-License-Identifier: AGPL-3.0-or-later diff --git a/roles/custom/matrix-client-hydrogen/templates/systemd/matrix-client-hydrogen.service.j2 b/roles/custom/matrix-client-hydrogen/templates/systemd/matrix-client-hydrogen.service.j2 deleted file mode 100644 index 1edf194fb..000000000 --- a/roles/custom/matrix-client-hydrogen/templates/systemd/matrix-client-hydrogen.service.j2 +++ /dev/null @@ -1,50 +0,0 @@ -#jinja2: lstrip_blocks: True -[Unit] -Description=Matrix Hydrogen Client -{% for service in hydrogen_systemd_required_services_list %} -Requires={{ service }} -After={{ service }} -{% endfor %} -DefaultDependencies=no - -[Service] -Type=simple -Environment="HOME={{ devture_systemd_docker_base_systemd_unit_home_path }}" -ExecStartPre=-{{ devture_systemd_docker_base_host_command_sh }} -c '{{ devture_systemd_docker_base_host_command_docker }} stop -t {{ devture_systemd_docker_base_container_stop_grace_time_seconds }} hydrogen 2>/dev/null || true' -ExecStartPre=-{{ devture_systemd_docker_base_host_command_sh }} -c '{{ devture_systemd_docker_base_host_command_docker }} rm hydrogen 2>/dev/null || true' - -ExecStartPre={{ devture_systemd_docker_base_host_command_docker }} create \ - --rm \ - --name=hydrogen \ - --log-driver=none \ - --user={{ matrix_user_uid }}:{{ matrix_user_gid }} \ - --cap-drop=ALL \ - --read-only \ - --network={{ hydrogen_container_network }} \ - {% if hydrogen_container_http_host_bind_port %} - -p {{ hydrogen_container_http_host_bind_port }}:8080 \ - {% endif %} - --label-file={{ hydrogen_base_path }}/labels \ - --tmpfs=/tmp:rw,noexec,nosuid,size=10m \ - --mount type=bind,src={{ hydrogen_base_path }}/nginx.conf,dst=/etc/nginx/nginx.conf,ro \ - --mount type=bind,src={{ hydrogen_base_path }}/config.json,dst=/config.json.bundled,ro \ - {% for arg in hydrogen_container_extra_arguments %} - {{ arg }} \ - {% endfor %} - {{ hydrogen_container_image }} - -{% for network in hydrogen_container_additional_networks %} -ExecStartPre={{ devture_systemd_docker_base_host_command_docker }} network connect {{ network }} hydrogen -{% endfor %} - -ExecStart={{ devture_systemd_docker_base_host_command_docker }} start --attach hydrogen - -ExecStop=-{{ devture_systemd_docker_base_host_command_sh }} -c '{{ devture_systemd_docker_base_host_command_docker }} stop -t {{ devture_systemd_docker_base_container_stop_grace_time_seconds }} hydrogen 2>/dev/null || true' -ExecStop=-{{ devture_systemd_docker_base_host_command_sh }} -c '{{ devture_systemd_docker_base_host_command_docker }} rm hydrogen 2>/dev/null || true' - -Restart=always -RestartSec=30 -SyslogIdentifier=hydrogen - -[Install] -WantedBy=multi-user.target diff --git a/roles/custom/matrix-client-hydrogen/templates/systemd/matrix-client-hydrogen.service.j2.license b/roles/custom/matrix-client-hydrogen/templates/systemd/matrix-client-hydrogen.service.j2.license deleted file mode 100644 index 0379e85ae..000000000 --- a/roles/custom/matrix-client-hydrogen/templates/systemd/matrix-client-hydrogen.service.j2.license +++ /dev/null @@ -1,5 +0,0 @@ -SPDX-FileCopyrightText: 2021 - 2025 Slavi Pantaleev -SPDX-FileCopyrightText: 2021 Aaron Raimist -SPDX-FileCopyrightText: 2022 Matthew Cengia - -SPDX-License-Identifier: AGPL-3.0-or-later