From d9bee18dddacc24ce01fe5c2764906a616e9ee4e Mon Sep 17 00:00:00 2001 From: Slavi Pantaleev Date: Thu, 16 Jul 2026 14:43:00 +0300 Subject: [PATCH] Rename matrix_mautrix_wsproxy_* variables to matrix_bridge_mautrix_wsproxy_* Part of adopting a uniform naming policy for bridge variables, where the variable prefix matches the role directory name. The companion appservice variables defined by this role are folded under the role prefix as well: matrix_mautrix_androidsms_* becomes matrix_bridge_mautrix_wsproxy_androidsms_* and matrix_mautrix_imessage_* becomes matrix_bridge_mautrix_wsproxy_imessage_*. matrix_mautrix_signal_wsproxy_syncproxy_connection_string becomes matrix_bridge_mautrix_wsproxy_syncproxy_connection_string, aligning it with the sibling matrix_bridge_mautrix_wsproxy_syncproxy_* variables. Co-Authored-By: Claude Fable 5 --- ...iguring-playbook-bridge-mautrix-wsproxy.md | 16 +- group_vars/matrix_servers | 60 +++--- .../defaults/main.yml | 182 +++++++++--------- .../tasks/main.yml | 6 +- .../tasks/setup_install.yml | 88 ++++----- .../tasks/setup_uninstall.yml | 16 +- .../tasks/validate_config.yml | 36 ++-- .../templates/config.yaml.j2 | 14 +- .../templates/syncproxy-env.j2 | 6 +- ...atrix-mautrix-wsproxy-syncproxy.service.j2 | 16 +- .../systemd/matrix-mautrix-wsproxy.service.j2 | 22 +-- .../templates/wsproxy-labels.j2 | 28 +-- 12 files changed, 245 insertions(+), 245 deletions(-) diff --git a/docs/configuring-playbook-bridge-mautrix-wsproxy.md b/docs/configuring-playbook-bridge-mautrix-wsproxy.md index a0d95d68b..1319aa934 100644 --- a/docs/configuring-playbook-bridge-mautrix-wsproxy.md +++ b/docs/configuring-playbook-bridge-mautrix-wsproxy.md @@ -25,26 +25,26 @@ When setting, replace `example.com` with your own. To enable the bridge, add the following configuration to your `inventory/host_vars/matrix.example.com/vars.yml` file: ```yaml -matrix_mautrix_wsproxy_enabled: true +matrix_bridge_mautrix_wsproxy_enabled: true -matrix_mautrix_androidsms_appservice_token: 'secret token from bridge' -matrix_mautrix_androidsms_homeserver_token: 'secret token from bridge' -matrix_mautrix_imessage_appservice_token: 'secret token from bridge' -matrix_mautrix_imessage_homeserver_token: 'secret token from bridge' -matrix_mautrix_wsproxy_syncproxy_shared_secret: 'secret token from bridge' +matrix_bridge_mautrix_wsproxy_androidsms_appservice_token: 'secret token from bridge' +matrix_bridge_mautrix_wsproxy_androidsms_homeserver_token: 'secret token from bridge' +matrix_bridge_mautrix_wsproxy_imessage_appservice_token: 'secret token from bridge' +matrix_bridge_mautrix_wsproxy_imessage_homeserver_token: 'secret token from bridge' +matrix_bridge_mautrix_wsproxy_syncproxy_shared_secret: 'secret token from bridge' ``` Note that the tokens must match what is compiled into the [mautrix-imessage](https://github.com/mautrix/imessage) bridge running on your Mac or Android device. ### Adjusting the wsproxy URL (optional) -By tweaking the `matrix_mautrix_wsproxy_hostname` variable, you can easily make the service available at a **different hostname** than the default one. +By tweaking the `matrix_bridge_mautrix_wsproxy_hostname` variable, you can easily make the service available at a **different hostname** than the default one. Example additional configuration for your `vars.yml` file: ```yaml # Change the default hostname -matrix_mautrix_wsproxy_hostname: ws.example.com +matrix_bridge_mautrix_wsproxy_hostname: ws.example.com ``` After changing the domain, **you may need to adjust your DNS** records to point the wsproxy domain to the Matrix server. diff --git a/group_vars/matrix_servers b/group_vars/matrix_servers index 68c82b73b..1c04c7d11 100755 --- a/group_vars/matrix_servers +++ b/group_vars/matrix_servers @@ -136,9 +136,9 @@ matrix_homeserver_container_extra_arguments_auto: | + (['--mount type=bind,src=' + matrix_mautrix_whatsapp_config_path + '/registration.yaml,dst=/matrix-mautrix-whatsapp-registration.yaml,ro'] if matrix_mautrix_whatsapp_enabled else []) + - (['--mount type=bind,src=' + matrix_mautrix_wsproxy_config_path + '/androidsms-registration.yaml,dst=/matrix-mautrix-androidsms-registration.yaml,ro'] if matrix_mautrix_wsproxy_enabled else []) + (['--mount type=bind,src=' + matrix_bridge_mautrix_wsproxy_config_path + '/androidsms-registration.yaml,dst=/matrix-mautrix-androidsms-registration.yaml,ro'] if matrix_bridge_mautrix_wsproxy_enabled else []) + - (['--mount type=bind,src=' + matrix_mautrix_wsproxy_config_path + '/imessage-registration.yaml,dst=/matrix-mautrix-imessage-registration.yaml,ro'] if matrix_mautrix_wsproxy_enabled else []) + (['--mount type=bind,src=' + matrix_bridge_mautrix_wsproxy_config_path + '/imessage-registration.yaml,dst=/matrix-mautrix-imessage-registration.yaml,ro'] if matrix_bridge_mautrix_wsproxy_enabled else []) + (['--mount type=bind,src=' + matrix_mx_puppet_groupme_config_path + '/registration.yaml,dst=/matrix-mx-puppet-groupme-registration.yaml,ro'] if matrix_mx_puppet_groupme_enabled else []) + @@ -195,9 +195,9 @@ matrix_homeserver_app_service_config_files_auto: | + (['/matrix-mautrix-whatsapp-registration.yaml'] if matrix_mautrix_whatsapp_enabled else []) + - (['/matrix-mautrix-androidsms-registration.yaml'] if matrix_mautrix_wsproxy_enabled else []) + (['/matrix-mautrix-androidsms-registration.yaml'] if matrix_bridge_mautrix_wsproxy_enabled else []) + - (['/matrix-mautrix-imessage-registration.yaml'] if matrix_mautrix_wsproxy_enabled else []) + (['/matrix-mautrix-imessage-registration.yaml'] if matrix_bridge_mautrix_wsproxy_enabled else []) + (['/matrix-mx-puppet-groupme-registration.yaml'] if matrix_mx_puppet_groupme_enabled else []) + @@ -506,16 +506,16 @@ devture_systemd_service_manager_services_list_auto: | ([{ 'name': 'matrix-mautrix-wsproxy.service', 'priority': 2000, - 'restart_necessary': (matrix_mautrix_wsproxy_restart_necessary | bool), + 'restart_necessary': (matrix_bridge_mautrix_wsproxy_restart_necessary | bool), 'groups': ['matrix', 'bridges', 'mautrix-wsproxy'], - }] if matrix_mautrix_wsproxy_enabled else []) + }] if matrix_bridge_mautrix_wsproxy_enabled else []) + ([{ 'name': 'matrix-mautrix-wsproxy-syncproxy.service', 'priority': 2000, - 'restart_necessary': (matrix_mautrix_wsproxy_syncproxy_restart_necessary | bool), + 'restart_necessary': (matrix_bridge_mautrix_wsproxy_syncproxy_restart_necessary | bool), 'groups': ['matrix', 'bridges', 'mautrix-wsproxy-syncproxy'], - }] if matrix_mautrix_wsproxy_enabled else []) + }] if matrix_bridge_mautrix_wsproxy_enabled else []) + ([{ 'name': 'matrix-mx-puppet-groupme.service', @@ -2298,43 +2298,43 @@ matrix_mautrix_gvoice_database_password: "{{ (matrix_homeserver_generic_secret_k ###################################################################### # We don't enable bridges by default. -matrix_mautrix_wsproxy_enabled: false +matrix_bridge_mautrix_wsproxy_enabled: false -matrix_mautrix_wsproxy_systemd_required_services_list_default: | +matrix_bridge_mautrix_wsproxy_systemd_required_services_list_default: | {{ matrix_addons_homeserver_systemd_services_list + - ([postgres_identifier ~ '.service'] if (postgres_enabled and matrix_mautrix_wsproxy_syncproxy_database_hostname == postgres_connection_hostname) else []) + ([postgres_identifier ~ '.service'] if (postgres_enabled and matrix_bridge_mautrix_wsproxy_syncproxy_database_hostname == postgres_connection_hostname) else []) }} -matrix_mautrix_wsproxy_homeserver_address: "{{ matrix_addons_homeserver_client_api_url }}" +matrix_bridge_mautrix_wsproxy_homeserver_address: "{{ matrix_addons_homeserver_client_api_url }}" -matrix_mautrix_wsproxy_hostname: "wsproxy.{{ matrix_mautrix_wsproxy_homeserver_domain }}" +matrix_bridge_mautrix_wsproxy_hostname: "wsproxy.{{ matrix_bridge_mautrix_wsproxy_homeserver_domain }}" -matrix_mautrix_wsproxy_syncproxy_homeserver_url: "{{ matrix_addons_homeserver_client_api_url }}" +matrix_bridge_mautrix_wsproxy_syncproxy_homeserver_url: "{{ matrix_addons_homeserver_client_api_url }}" -matrix_mautrix_wsproxy_container_image_registry_prefix_upstream: "{{ matrix_container_global_registry_prefix_override if matrix_container_global_registry_prefix_override else matrix_mautrix_wsproxy_container_image_registry_prefix_upstream_default }}" +matrix_bridge_mautrix_wsproxy_container_image_registry_prefix_upstream: "{{ matrix_container_global_registry_prefix_override if matrix_container_global_registry_prefix_override else matrix_bridge_mautrix_wsproxy_container_image_registry_prefix_upstream_default }}" -matrix_mautrix_wsproxy_container_network: "{{ matrix_addons_container_network }}" +matrix_bridge_mautrix_wsproxy_container_network: "{{ matrix_addons_container_network }}" -matrix_mautrix_wsproxy_container_additional_networks: | +matrix_bridge_mautrix_wsproxy_container_additional_networks: | {{ ( ([] if matrix_addons_homeserver_container_network == '' else [matrix_addons_homeserver_container_network]) + ([matrix_playbook_reverse_proxyable_services_additional_network] if matrix_playbook_reverse_proxyable_services_additional_network else []) + - ([postgres_container_network] if (postgres_enabled and matrix_mautrix_wsproxy_syncproxy_database_hostname == postgres_connection_hostname and postgres_container_network != matrix_mautrix_wsproxy_container_network) else []) + ([postgres_container_network] if (postgres_enabled and matrix_bridge_mautrix_wsproxy_syncproxy_database_hostname == postgres_connection_hostname and postgres_container_network != matrix_bridge_mautrix_wsproxy_container_network) else []) ) | unique }} -matrix_mautrix_wsproxy_container_labels_traefik_enabled: "{{ matrix_playbook_reverse_proxy_type in ['playbook-managed-traefik', 'other-traefik-container'] }}" -matrix_mautrix_wsproxy_container_labels_traefik_docker_network: "{{ matrix_playbook_reverse_proxyable_services_additional_network }}" -matrix_mautrix_wsproxy_container_labels_traefik_entrypoints: "{{ traefik_entrypoint_primary }}" -matrix_mautrix_wsproxy_container_labels_traefik_tls_certResolver: "{{ traefik_certResolver_primary }}" +matrix_bridge_mautrix_wsproxy_container_labels_traefik_enabled: "{{ matrix_playbook_reverse_proxy_type in ['playbook-managed-traefik', 'other-traefik-container'] }}" +matrix_bridge_mautrix_wsproxy_container_labels_traefik_docker_network: "{{ matrix_playbook_reverse_proxyable_services_additional_network }}" +matrix_bridge_mautrix_wsproxy_container_labels_traefik_entrypoints: "{{ traefik_entrypoint_primary }}" +matrix_bridge_mautrix_wsproxy_container_labels_traefik_tls_certResolver: "{{ traefik_certResolver_primary }}" -matrix_mautrix_wsproxy_syncproxy_database_hostname: "{{ postgres_connection_hostname if postgres_enabled else '' }}" -matrix_mautrix_wsproxy_syncproxy_database_password: "{{ (matrix_homeserver_generic_secret_key + ':wsproxy.db') | hash('sha512') | to_uuid }}" +matrix_bridge_mautrix_wsproxy_syncproxy_database_hostname: "{{ postgres_connection_hostname if postgres_enabled else '' }}" +matrix_bridge_mautrix_wsproxy_syncproxy_database_password: "{{ (matrix_homeserver_generic_secret_key + ':wsproxy.db') | hash('sha512') | to_uuid }}" ###################################################################### # @@ -4207,10 +4207,10 @@ postgres_managed_databases_auto: | }] if (matrix_mautrix_meta_instagram_enabled and matrix_mautrix_meta_instagram_database_engine == 'postgres' and matrix_mautrix_meta_instagram_database_hostname == postgres_connection_hostname) else []) + ([{ - 'name': matrix_mautrix_wsproxy_syncproxy_database_name, - 'username': matrix_mautrix_wsproxy_syncproxy_database_username, - 'password': matrix_mautrix_wsproxy_syncproxy_database_password, - }] if (matrix_mautrix_wsproxy_enabled and matrix_mautrix_wsproxy_syncproxy_database_engine == 'postgres' and matrix_mautrix_wsproxy_syncproxy_database_hostname == 'matrix-postgres') else []) + 'name': matrix_bridge_mautrix_wsproxy_syncproxy_database_name, + 'username': matrix_bridge_mautrix_wsproxy_syncproxy_database_username, + 'password': matrix_bridge_mautrix_wsproxy_syncproxy_database_password, + }] if (matrix_bridge_mautrix_wsproxy_enabled and matrix_bridge_mautrix_wsproxy_syncproxy_database_engine == 'postgres' and matrix_bridge_mautrix_wsproxy_syncproxy_database_hostname == 'matrix-postgres') else []) + ([{ 'name': matrix_mautrix_telegram_database_name, @@ -5186,9 +5186,9 @@ matrix_ketesa_config_asManagedUsers_auto: | ] if matrix_mautrix_whatsapp_enabled else []) + ([ - '^@'+(matrix_mautrix_imessage_appservice_bot_username | default('') | regex_escape)+':'+(matrix_domain | regex_escape)+'$', + '^@'+(matrix_bridge_mautrix_wsproxy_imessage_appservice_bot_username | default('') | regex_escape)+':'+(matrix_domain | regex_escape)+'$', '^@imessage_[a-zA-Z0-9]+:'+(matrix_domain | regex_escape)+'$', - ] if matrix_mautrix_wsproxy_enabled else []) + ] if matrix_bridge_mautrix_wsproxy_enabled else []) + ([ '^@_groupmepuppet_[a-zA-Z0-9]+:'+(matrix_domain | regex_escape)+'$', diff --git a/roles/custom/matrix-bridge-mautrix-wsproxy/defaults/main.yml b/roles/custom/matrix-bridge-mautrix-wsproxy/defaults/main.yml index ce052a674..8592b3529 100644 --- a/roles/custom/matrix-bridge-mautrix-wsproxy/defaults/main.yml +++ b/roles/custom/matrix-bridge-mautrix-wsproxy/defaults/main.yml @@ -9,175 +9,175 @@ # mautrix-wsproxy is a Matrix <-> websocket bridge # See: https://github.com/mautrix/wsproxy -matrix_mautrix_wsproxy_enabled: true +matrix_bridge_mautrix_wsproxy_enabled: true -matrix_mautrix_wsproxy_version: latest +matrix_bridge_mautrix_wsproxy_version: latest # See: https://mau.dev/mautrix/wsproxy/container_registry -matrix_mautrix_wsproxy_container_image: "{{ matrix_mautrix_wsproxy_container_image_registry_prefix }}mautrix/wsproxy:{{ matrix_mautrix_wsproxy_version }}" -matrix_mautrix_wsproxy_container_image_registry_prefix: "{{ matrix_mautrix_wsproxy_container_image_registry_prefix_upstream }}" -matrix_mautrix_wsproxy_container_image_registry_prefix_upstream: "{{ matrix_mautrix_wsproxy_container_image_registry_prefix_upstream_default }}" -matrix_mautrix_wsproxy_container_image_registry_prefix_upstream_default: "dock.mau.dev/" +matrix_bridge_mautrix_wsproxy_container_image: "{{ matrix_bridge_mautrix_wsproxy_container_image_registry_prefix }}mautrix/wsproxy:{{ matrix_bridge_mautrix_wsproxy_version }}" +matrix_bridge_mautrix_wsproxy_container_image_registry_prefix: "{{ matrix_bridge_mautrix_wsproxy_container_image_registry_prefix_upstream }}" +matrix_bridge_mautrix_wsproxy_container_image_registry_prefix_upstream: "{{ matrix_bridge_mautrix_wsproxy_container_image_registry_prefix_upstream_default }}" +matrix_bridge_mautrix_wsproxy_container_image_registry_prefix_upstream_default: "dock.mau.dev/" -matrix_mautrix_wsproxy_base_path: "{{ matrix_base_data_path }}/wsproxy" -matrix_mautrix_wsproxy_config_path: "{{ matrix_mautrix_wsproxy_base_path }}/config" +matrix_bridge_mautrix_wsproxy_base_path: "{{ matrix_base_data_path }}/wsproxy" +matrix_bridge_mautrix_wsproxy_config_path: "{{ matrix_bridge_mautrix_wsproxy_base_path }}/config" -matrix_mautrix_wsproxy_homeserver_address: "" -matrix_mautrix_wsproxy_homeserver_domain: "{{ matrix_domain }}" +matrix_bridge_mautrix_wsproxy_homeserver_address: "" +matrix_bridge_mautrix_wsproxy_homeserver_domain: "{{ matrix_domain }}" -matrix_mautrix_wsproxy_bind_port: false -matrix_mautrix_wsproxy_port: 29331 +matrix_bridge_mautrix_wsproxy_bind_port: false +matrix_bridge_mautrix_wsproxy_port: 29331 -matrix_mautrix_wsproxy_appservice_address: "http://matrix-mautrix-wsproxy:{{ matrix_mautrix_wsproxy_port }}" +matrix_bridge_mautrix_wsproxy_appservice_address: "http://matrix-mautrix-wsproxy:{{ matrix_bridge_mautrix_wsproxy_port }}" -matrix_mautrix_wsproxy_hostname: "" +matrix_bridge_mautrix_wsproxy_hostname: "" # The base container network. It will be auto-created by this role if it doesn't exist already. -matrix_mautrix_wsproxy_container_network: matrix-mautrix-wsproxy +matrix_bridge_mautrix_wsproxy_container_network: matrix-mautrix-wsproxy -matrix_mautrix_wsproxy_twitter_container_additional_networks: "{{ matrix_mautrix_wsproxy_twitter_container_additional_networks_auto + matrix_mautrix_wsproxy_twitter_container_additional_networks_custom }}" -matrix_mautrix_wsproxy_twitter_container_additional_networks_auto: [] -matrix_mautrix_wsproxy_twitter_container_additional_networks_custom: [] +matrix_bridge_mautrix_wsproxy_twitter_container_additional_networks: "{{ matrix_bridge_mautrix_wsproxy_twitter_container_additional_networks_auto + matrix_bridge_mautrix_wsproxy_twitter_container_additional_networks_custom }}" +matrix_bridge_mautrix_wsproxy_twitter_container_additional_networks_auto: [] +matrix_bridge_mautrix_wsproxy_twitter_container_additional_networks_custom: [] -# matrix_mautrix_wsproxy_container_labels_traefik_enabled controls whether labels to assist a Traefik reverse-proxy will be attached to the container. +# matrix_bridge_mautrix_wsproxy_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_mautrix_wsproxy_container_labels_additional_labels`. -matrix_mautrix_wsproxy_container_labels_traefik_enabled: true -matrix_mautrix_wsproxy_container_labels_traefik_docker_network: "{{ matrix_mautrix_wsproxy_container_network }}" -matrix_mautrix_wsproxy_container_labels_traefik_hostname: "{{ matrix_mautrix_wsproxy_hostname }}" +# To inject your own other container labels, see `matrix_bridge_mautrix_wsproxy_container_labels_additional_labels`. +matrix_bridge_mautrix_wsproxy_container_labels_traefik_enabled: true +matrix_bridge_mautrix_wsproxy_container_labels_traefik_docker_network: "{{ matrix_bridge_mautrix_wsproxy_container_network }}" +matrix_bridge_mautrix_wsproxy_container_labels_traefik_hostname: "{{ matrix_bridge_mautrix_wsproxy_hostname }}" # The path prefix must either be `/` or not end with a slash (e.g. `/wsproxy`). -matrix_mautrix_wsproxy_container_labels_traefik_rule: "Host(`{{ matrix_mautrix_wsproxy_container_labels_traefik_hostname }}`)" -matrix_mautrix_wsproxy_container_labels_traefik_priority: 0 -matrix_mautrix_wsproxy_container_labels_traefik_entrypoints: web-secure -matrix_mautrix_wsproxy_container_labels_traefik_tls: "{{ matrix_mautrix_wsproxy_container_labels_traefik_entrypoints != 'web' }}" -matrix_mautrix_wsproxy_container_labels_traefik_tls_certResolver: default # noqa var-naming +matrix_bridge_mautrix_wsproxy_container_labels_traefik_rule: "Host(`{{ matrix_bridge_mautrix_wsproxy_container_labels_traefik_hostname }}`)" +matrix_bridge_mautrix_wsproxy_container_labels_traefik_priority: 0 +matrix_bridge_mautrix_wsproxy_container_labels_traefik_entrypoints: web-secure +matrix_bridge_mautrix_wsproxy_container_labels_traefik_tls: "{{ matrix_bridge_mautrix_wsproxy_container_labels_traefik_entrypoints != 'web' }}" +matrix_bridge_mautrix_wsproxy_container_labels_traefik_tls_certResolver: default # noqa var-naming # Controls which additional headers to attach to all HTTP responses. -# To add your own headers, use `matrix_mautrix_wsproxy_container_labels_traefik_additional_response_headers_custom` -matrix_mautrix_wsproxy_container_labels_traefik_additional_response_headers_auto: {} -matrix_mautrix_wsproxy_container_labels_traefik_additional_response_headers_custom: {} -matrix_mautrix_wsproxy_container_labels_traefik_additional_response_headers: "{{ matrix_mautrix_wsproxy_container_labels_traefik_additional_response_headers_auto | combine(matrix_mautrix_wsproxy_container_labels_traefik_additional_response_headers_custom) }}" +# To add your own headers, use `matrix_bridge_mautrix_wsproxy_container_labels_traefik_additional_response_headers_custom` +matrix_bridge_mautrix_wsproxy_container_labels_traefik_additional_response_headers_auto: {} +matrix_bridge_mautrix_wsproxy_container_labels_traefik_additional_response_headers_custom: {} +matrix_bridge_mautrix_wsproxy_container_labels_traefik_additional_response_headers: "{{ matrix_bridge_mautrix_wsproxy_container_labels_traefik_additional_response_headers_auto | combine(matrix_bridge_mautrix_wsproxy_container_labels_traefik_additional_response_headers_custom) }}" -# matrix_mautrix_wsproxy_container_labels_additional_labels contains a multiline string with additional labels to add to the container label file. +# matrix_bridge_mautrix_wsproxy_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_mautrix_wsproxy_container_labels_additional_labels: | +# matrix_bridge_mautrix_wsproxy_container_labels_additional_labels: | # my.label=1 # another.label="here" -matrix_mautrix_wsproxy_container_labels_additional_labels: '' +matrix_bridge_mautrix_wsproxy_container_labels_additional_labels: '' # A list of extra arguments to pass to the container -matrix_mautrix_wsproxy_container_extra_arguments: [] +matrix_bridge_mautrix_wsproxy_container_extra_arguments: [] # List of systemd services that matrix-mautrix-wsproxy.service depends on. -matrix_mautrix_wsproxy_systemd_required_services_list: "{{ matrix_mautrix_wsproxy_systemd_required_services_list_default + matrix_mautrix_wsproxy_systemd_required_services_list_auto + matrix_mautrix_wsproxy_systemd_required_services_list_custom }}" -matrix_mautrix_wsproxy_systemd_required_services_list_default: "{{ [devture_systemd_docker_base_docker_service_name] if devture_systemd_docker_base_docker_service_name else [] }}" -matrix_mautrix_wsproxy_systemd_required_services_list_auto: [] -matrix_mautrix_wsproxy_systemd_required_services_list_custom: [] +matrix_bridge_mautrix_wsproxy_systemd_required_services_list: "{{ matrix_bridge_mautrix_wsproxy_systemd_required_services_list_default + matrix_bridge_mautrix_wsproxy_systemd_required_services_list_auto + matrix_bridge_mautrix_wsproxy_systemd_required_services_list_custom }}" +matrix_bridge_mautrix_wsproxy_systemd_required_services_list_default: "{{ [devture_systemd_docker_base_docker_service_name] if devture_systemd_docker_base_docker_service_name else [] }}" +matrix_bridge_mautrix_wsproxy_systemd_required_services_list_auto: [] +matrix_bridge_mautrix_wsproxy_systemd_required_services_list_custom: [] # List of systemd services that matrix-mautrix-wsproxy.service wants -matrix_mautrix_wsproxy_systemd_wanted_services_list: [] +matrix_bridge_mautrix_wsproxy_systemd_wanted_services_list: [] -matrix_mautrix_androidsms_appservice_token: '' -matrix_mautrix_androidsms_homeserver_token: '' +matrix_bridge_mautrix_wsproxy_androidsms_appservice_token: '' +matrix_bridge_mautrix_wsproxy_androidsms_homeserver_token: '' -matrix_mautrix_imessage_appservice_token: '' -matrix_mautrix_imessage_homeserver_token: '' +matrix_bridge_mautrix_wsproxy_imessage_appservice_token: '' +matrix_bridge_mautrix_wsproxy_imessage_homeserver_token: '' -matrix_mautrix_androidsms_appservice_bot_username: androidsmsbot -matrix_mautrix_imessage_appservice_bot_username: imessagebot +matrix_bridge_mautrix_wsproxy_androidsms_appservice_bot_username: androidsmsbot +matrix_bridge_mautrix_wsproxy_imessage_appservice_bot_username: imessagebot # Default mautrix-wsproxy 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_mautrix_wsproxy_configuration_extension_yaml`) +# For a more advanced customization, you can extend the default (see `matrix_bridge_mautrix_wsproxy_configuration_extension_yaml`) # or completely replace this variable with your own template. -matrix_mautrix_wsproxy_configuration_yaml: "{{ lookup('template', 'templates/config.yaml.j2') }}" +matrix_bridge_mautrix_wsproxy_configuration_yaml: "{{ lookup('template', 'templates/config.yaml.j2') }}" -matrix_mautrix_wsproxy_configuration_extension_yaml: | +matrix_bridge_mautrix_wsproxy_configuration_extension_yaml: | # Your custom YAML configuration goes here. - # This configuration extends the default starting configuration (`matrix_mautrix_wsproxy_configuration_yaml`). + # This configuration extends the default starting configuration (`matrix_bridge_mautrix_wsproxy_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_mautrix_wsproxy_configuration_yaml`. + # completely redefining `matrix_bridge_mautrix_wsproxy_configuration_yaml`. -matrix_mautrix_wsproxy_configuration_extension: "{{ matrix_mautrix_wsproxy_configuration_extension_yaml | from_yaml if matrix_mautrix_wsproxy_configuration_extension_yaml | from_yaml is mapping else {} }}" +matrix_bridge_mautrix_wsproxy_configuration_extension: "{{ matrix_bridge_mautrix_wsproxy_configuration_extension_yaml | from_yaml if matrix_bridge_mautrix_wsproxy_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_mautrix_wsproxy_configuration_yaml`. -matrix_mautrix_wsproxy_configuration: "{{ matrix_mautrix_wsproxy_configuration_yaml | from_yaml | combine(matrix_mautrix_wsproxy_configuration_extension, recursive=True) }}" +# You most likely don't need to touch this variable. Instead, see `matrix_bridge_mautrix_wsproxy_configuration_yaml`. +matrix_bridge_mautrix_wsproxy_configuration: "{{ matrix_bridge_mautrix_wsproxy_configuration_yaml | from_yaml | combine(matrix_bridge_mautrix_wsproxy_configuration_extension, recursive=True) }}" -matrix_mautrix_androidsms_registration_yaml: | +matrix_bridge_mautrix_wsproxy_androidsms_registration_yaml: | id: androidsms - url: {{ matrix_mautrix_wsproxy_appservice_address }} - as_token: "{{ matrix_mautrix_androidsms_appservice_token }}" - hs_token: "{{ matrix_mautrix_androidsms_homeserver_token }}" - sender_localpart: _bot_{{ matrix_mautrix_androidsms_appservice_bot_username }} + url: {{ matrix_bridge_mautrix_wsproxy_appservice_address }} + as_token: "{{ matrix_bridge_mautrix_wsproxy_androidsms_appservice_token }}" + hs_token: "{{ matrix_bridge_mautrix_wsproxy_androidsms_homeserver_token }}" + sender_localpart: _bot_{{ matrix_bridge_mautrix_wsproxy_androidsms_appservice_bot_username }} rate_limited: false namespaces: users: - - regex: '@androidsms_.+:{{ matrix_mautrix_wsproxy_homeserver_domain | regex_escape }}$' + - regex: '@androidsms_.+:{{ matrix_bridge_mautrix_wsproxy_homeserver_domain | regex_escape }}$' exclusive: true - exclusive: true - regex: '^@{{ matrix_mautrix_androidsms_appservice_bot_username | regex_escape }}:{{ matrix_mautrix_wsproxy_homeserver_domain | regex_escape }}$' + regex: '^@{{ matrix_bridge_mautrix_wsproxy_androidsms_appservice_bot_username | regex_escape }}:{{ matrix_bridge_mautrix_wsproxy_homeserver_domain | regex_escape }}$' -matrix_mautrix_androidsms_registration: "{{ matrix_mautrix_androidsms_registration_yaml | from_yaml }}" +matrix_bridge_mautrix_wsproxy_androidsms_registration: "{{ matrix_bridge_mautrix_wsproxy_androidsms_registration_yaml | from_yaml }}" -matrix_mautrix_imessage_registration_yaml: | +matrix_bridge_mautrix_wsproxy_imessage_registration_yaml: | id: imessage - url: {{ matrix_mautrix_wsproxy_appservice_address }} - as_token: "{{ matrix_mautrix_imessage_appservice_token }}" - hs_token: "{{ matrix_mautrix_imessage_homeserver_token }}" - sender_localpart: _bot_{{ matrix_mautrix_imessage_appservice_bot_username }} + url: {{ matrix_bridge_mautrix_wsproxy_appservice_address }} + as_token: "{{ matrix_bridge_mautrix_wsproxy_imessage_appservice_token }}" + hs_token: "{{ matrix_bridge_mautrix_wsproxy_imessage_homeserver_token }}" + sender_localpart: _bot_{{ matrix_bridge_mautrix_wsproxy_imessage_appservice_bot_username }} rate_limited: false namespaces: users: - - regex: '@imessage_.+:{{ matrix_mautrix_wsproxy_homeserver_domain | regex_escape }}$' + - regex: '@imessage_.+:{{ matrix_bridge_mautrix_wsproxy_homeserver_domain | regex_escape }}$' exclusive: true - exclusive: true - regex: '^@{{ matrix_mautrix_imessage_appservice_bot_username | regex_escape }}:{{ matrix_mautrix_wsproxy_homeserver_domain | regex_escape }}$' + regex: '^@{{ matrix_bridge_mautrix_wsproxy_imessage_appservice_bot_username | regex_escape }}:{{ matrix_bridge_mautrix_wsproxy_homeserver_domain | regex_escape }}$' -matrix_mautrix_imessage_registration: "{{ matrix_mautrix_imessage_registration_yaml | from_yaml }}" +matrix_bridge_mautrix_wsproxy_imessage_registration: "{{ matrix_bridge_mautrix_wsproxy_imessage_registration_yaml | from_yaml }}" # Syncproxy-related configuration fields # renovate: datasource=docker depName=dock.mau.dev/mautrix/syncproxy -matrix_mautrix_wsproxy_syncproxy_version: latest +matrix_bridge_mautrix_wsproxy_syncproxy_version: latest # See: https://mau.dev/mautrix/wsproxy/container_registry -matrix_mautrix_wsproxy_syncproxy_container_image: "dock.mau.dev/mautrix/syncproxy:{{ matrix_mautrix_wsproxy_syncproxy_version }}" -matrix_mautrix_wsproxy_syncproxy_container_extra_arguments: [] +matrix_bridge_mautrix_wsproxy_syncproxy_container_image: "dock.mau.dev/mautrix/syncproxy:{{ matrix_bridge_mautrix_wsproxy_syncproxy_version }}" +matrix_bridge_mautrix_wsproxy_syncproxy_container_extra_arguments: [] -matrix_mautrix_wsproxy_syncproxy_systemd_required_services_list: |- +matrix_bridge_mautrix_wsproxy_syncproxy_systemd_required_services_list: |- {{ ([devture_systemd_docker_base_docker_service_name] if devture_systemd_docker_base_docker_service_name else []) + ['matrix-mautrix-wsproxy.service'] }} -matrix_mautrix_wsproxy_syncproxy_systemd_wanted_services_list: [] +matrix_bridge_mautrix_wsproxy_syncproxy_systemd_wanted_services_list: [] -matrix_mautrix_wsproxy_syncproxy_homeserver_url: '' +matrix_bridge_mautrix_wsproxy_syncproxy_homeserver_url: '' -matrix_mautrix_wsproxy_syncproxy_shared_secret: '' -matrix_mautrix_wsproxy_syncproxy_port: 29332 -matrix_mautrix_wsproxy_syncproxy_appservice_address: "http://matrix-mautrix-wsproxy-syncproxy:{{ matrix_mautrix_wsproxy_syncproxy_port }}" +matrix_bridge_mautrix_wsproxy_syncproxy_shared_secret: '' +matrix_bridge_mautrix_wsproxy_syncproxy_port: 29332 +matrix_bridge_mautrix_wsproxy_syncproxy_appservice_address: "http://matrix-mautrix-wsproxy-syncproxy:{{ matrix_bridge_mautrix_wsproxy_syncproxy_port }}" # Database-related configuration fields # # This bridge supports Postgres and SQLite. # -matrix_mautrix_wsproxy_syncproxy_database_engine: 'postgres' +matrix_bridge_mautrix_wsproxy_syncproxy_database_engine: 'postgres' -matrix_mautrix_wsproxy_syncproxy_database_username: 'matrix_mautrix_wsproxy_syncproxy' -matrix_mautrix_wsproxy_syncproxy_database_password: '' -matrix_mautrix_wsproxy_syncproxy_database_hostname: '' -matrix_mautrix_wsproxy_syncproxy_database_port: 5432 -matrix_mautrix_wsproxy_syncproxy_database_name: 'matrix_mautrix_wsproxy_syncproxy' +matrix_bridge_mautrix_wsproxy_syncproxy_database_username: 'matrix_bridge_mautrix_wsproxy_syncproxy' +matrix_bridge_mautrix_wsproxy_syncproxy_database_password: '' +matrix_bridge_mautrix_wsproxy_syncproxy_database_hostname: '' +matrix_bridge_mautrix_wsproxy_syncproxy_database_port: 5432 +matrix_bridge_mautrix_wsproxy_syncproxy_database_name: 'matrix_bridge_mautrix_wsproxy_syncproxy' -matrix_mautrix_signal_wsproxy_syncproxy_connection_string: 'postgres://{{ matrix_mautrix_wsproxy_syncproxy_database_username }}:{{ matrix_mautrix_wsproxy_syncproxy_database_password }}@{{ matrix_mautrix_wsproxy_syncproxy_database_hostname }}:{{ matrix_mautrix_wsproxy_syncproxy_database_port }}/{{ matrix_mautrix_wsproxy_syncproxy_database_name }}' +matrix_bridge_mautrix_wsproxy_syncproxy_connection_string: 'postgres://{{ matrix_bridge_mautrix_wsproxy_syncproxy_database_username }}:{{ matrix_bridge_mautrix_wsproxy_syncproxy_database_password }}@{{ matrix_bridge_mautrix_wsproxy_syncproxy_database_hostname }}:{{ matrix_bridge_mautrix_wsproxy_syncproxy_database_port }}/{{ matrix_bridge_mautrix_wsproxy_syncproxy_database_name }}' -# matrix_mautrix_wsproxy_restart_necessary controls whether the service +# matrix_bridge_mautrix_wsproxy_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). # @@ -185,9 +185,9 @@ matrix_mautrix_signal_wsproxy_syncproxy_connection_string: 'postgres://{{ matrix # 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_mautrix_wsproxy_restart_necessary: false +matrix_bridge_mautrix_wsproxy_restart_necessary: false -# matrix_mautrix_wsproxy_syncproxy_restart_necessary controls whether the service +# matrix_bridge_mautrix_wsproxy_syncproxy_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). # @@ -195,4 +195,4 @@ matrix_mautrix_wsproxy_restart_necessary: false # 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_mautrix_wsproxy_syncproxy_restart_necessary: false +matrix_bridge_mautrix_wsproxy_syncproxy_restart_necessary: false diff --git a/roles/custom/matrix-bridge-mautrix-wsproxy/tasks/main.yml b/roles/custom/matrix-bridge-mautrix-wsproxy/tasks/main.yml index dd2cee331..f1be51571 100644 --- a/roles/custom/matrix-bridge-mautrix-wsproxy/tasks/main.yml +++ b/roles/custom/matrix-bridge-mautrix-wsproxy/tasks/main.yml @@ -11,15 +11,15 @@ - install-all - install-mautrix-wsproxy block: - - when: matrix_mautrix_wsproxy_enabled | bool + - when: matrix_bridge_mautrix_wsproxy_enabled | bool ansible.builtin.include_tasks: "{{ role_path }}/tasks/validate_config.yml" - - when: matrix_mautrix_wsproxy_enabled | bool + - when: matrix_bridge_mautrix_wsproxy_enabled | bool ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_install.yml" - tags: - setup-all - setup-mautrix-wsproxy block: - - when: not matrix_mautrix_wsproxy_enabled | bool + - when: not matrix_bridge_mautrix_wsproxy_enabled | bool ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" diff --git a/roles/custom/matrix-bridge-mautrix-wsproxy/tasks/setup_install.yml b/roles/custom/matrix-bridge-mautrix-wsproxy/tasks/setup_install.yml index 94e61a3b7..3396ff4d9 100644 --- a/roles/custom/matrix-bridge-mautrix-wsproxy/tasks/setup_install.yml +++ b/roles/custom/matrix-bridge-mautrix-wsproxy/tasks/setup_install.yml @@ -16,10 +16,10 @@ when: "matrix_synapse_role_executed|default(False)" - ansible.builtin.set_fact: - matrix_mautrix_wsproxy_migration_requires_restart: false + matrix_bridge_mautrix_wsproxy_migration_requires_restart: false - ansible.builtin.set_fact: - matrix_mautrix_wsproxy_syncproxy_migration_requires_restart: false + matrix_bridge_mautrix_wsproxy_syncproxy_migration_requires_restart: false - name: Ensure Mautrix wsproxy paths exist ansible.builtin.file: @@ -29,39 +29,39 @@ owner: "{{ matrix_user_name }}" group: "{{ matrix_group_name }}" with_items: - - path: "{{ matrix_mautrix_wsproxy_base_path }}" + - path: "{{ matrix_bridge_mautrix_wsproxy_base_path }}" when: true when: item.when | bool - name: Ensure Mautrix wsproxy support files installed ansible.builtin.template: src: "{{ role_path }}/templates/{{ item }}.j2" - dest: "{{ matrix_mautrix_wsproxy_base_path }}/{{ item }}" + dest: "{{ matrix_bridge_mautrix_wsproxy_base_path }}/{{ item }}" mode: '0640' owner: "{{ matrix_user_name }}" group: "{{ matrix_group_name }}" with_items: - syncproxy-env - wsproxy-labels - register: matrix_mautrix_wsproxy_support_files_result + register: matrix_bridge_mautrix_wsproxy_support_files_result - name: Ensure Mautrix wsproxy image is pulled community.docker.docker_image_pull: - name: "{{ matrix_mautrix_wsproxy_container_image }}" + name: "{{ matrix_bridge_mautrix_wsproxy_container_image }}" pull: always - register: matrix_mautrix_wsproxy_container_image_pull_result + register: matrix_bridge_mautrix_wsproxy_container_image_pull_result retries: "{{ devture_playbook_help_container_retries_count }}" delay: "{{ devture_playbook_help_container_retries_delay }}" - until: matrix_mautrix_wsproxy_container_image_pull_result is not failed + until: matrix_bridge_mautrix_wsproxy_container_image_pull_result is not failed - name: Ensure Mautrix syncproxy image is pulled community.docker.docker_image_pull: - name: "{{ matrix_mautrix_wsproxy_syncproxy_container_image }}" + name: "{{ matrix_bridge_mautrix_wsproxy_syncproxy_container_image }}" pull: always - register: matrix_mautrix_wsproxy_syncproxy_container_image_pull_result + register: matrix_bridge_mautrix_wsproxy_syncproxy_container_image_pull_result retries: "{{ devture_playbook_help_container_retries_count }}" delay: "{{ devture_playbook_help_container_retries_delay }}" - until: matrix_mautrix_wsproxy_syncproxy_container_image_pull_result is not failed + until: matrix_bridge_mautrix_wsproxy_syncproxy_container_image_pull_result is not failed - name: Ensure Mautrix wsproxy paths exists ansible.builtin.file: @@ -71,46 +71,46 @@ owner: "{{ matrix_user_name }}" group: "{{ matrix_group_name }}" with_items: - - "{{ matrix_mautrix_wsproxy_base_path }}" - - "{{ matrix_mautrix_wsproxy_config_path }}" + - "{{ matrix_bridge_mautrix_wsproxy_base_path }}" + - "{{ matrix_bridge_mautrix_wsproxy_config_path }}" - name: Check if an old Matrix state file exists ansible.builtin.stat: - path: "{{ matrix_mautrix_wsproxy_base_path }}/mx-state.json" - register: matrix_mautrix_wsproxy_stat_mx_state + path: "{{ matrix_bridge_mautrix_wsproxy_base_path }}/mx-state.json" + register: matrix_bridge_mautrix_wsproxy_stat_mx_state - name: Ensure mautrix-wsproxy config.yaml installed ansible.builtin.copy: - content: "{{ matrix_mautrix_wsproxy_configuration | to_nice_yaml }}" - dest: "{{ matrix_mautrix_wsproxy_config_path }}/config.yaml" + content: "{{ matrix_bridge_mautrix_wsproxy_configuration | to_nice_yaml }}" + dest: "{{ matrix_bridge_mautrix_wsproxy_config_path }}/config.yaml" mode: '0644' owner: "{{ matrix_user_name }}" group: "{{ matrix_group_name }}" - register: matrix_mautrix_wsproxy_config_result + register: matrix_bridge_mautrix_wsproxy_config_result - name: Ensure mautrix-androidsms registration.yaml installed ansible.builtin.copy: - content: "{{ matrix_mautrix_androidsms_registration | to_nice_yaml }}" - dest: "{{ matrix_mautrix_wsproxy_config_path }}/androidsms-registration.yaml" + content: "{{ matrix_bridge_mautrix_wsproxy_androidsms_registration | to_nice_yaml }}" + dest: "{{ matrix_bridge_mautrix_wsproxy_config_path }}/androidsms-registration.yaml" mode: '0644' owner: "{{ matrix_user_name }}" group: "{{ matrix_group_name }}" - register: matrix_mautrix_wsproxy_registration_androidsms_result + register: matrix_bridge_mautrix_wsproxy_registration_androidsms_result - name: Ensure mautrix-imessage registration.yaml installed ansible.builtin.copy: - content: "{{ matrix_mautrix_imessage_registration | to_nice_yaml }}" - dest: "{{ matrix_mautrix_wsproxy_config_path }}/imessage-registration.yaml" + content: "{{ matrix_bridge_mautrix_wsproxy_imessage_registration | to_nice_yaml }}" + dest: "{{ matrix_bridge_mautrix_wsproxy_config_path }}/imessage-registration.yaml" mode: '0644' owner: "{{ matrix_user_name }}" group: "{{ matrix_group_name }}" - register: matrix_mautrix_wsproxy_registration_imessage_result + register: matrix_bridge_mautrix_wsproxy_registration_imessage_result - name: Ensure mautrix-wsproxy container network is created - when: matrix_mautrix_wsproxy_container_network != 'host' + when: matrix_bridge_mautrix_wsproxy_container_network != 'host' community.general.docker_network: enable_ipv6: "{{ devture_systemd_docker_base_ipv6_enabled }}" - name: "{{ matrix_mautrix_wsproxy_container_network }}" + name: "{{ matrix_bridge_mautrix_wsproxy_container_network }}" driver: bridge driver_options: "{{ devture_systemd_docker_base_container_networks_driver_options }}" @@ -119,55 +119,55 @@ src: "{{ role_path }}/templates/systemd/matrix-mautrix-wsproxy.service.j2" dest: "{{ devture_systemd_docker_base_systemd_path }}/matrix-mautrix-wsproxy.service" mode: '0644' - register: matrix_mautrix_wsproxy_systemd_service_result + register: matrix_bridge_mautrix_wsproxy_systemd_service_result - name: Determine whether Mautrix wsproxy needs a restart ansible.builtin.set_fact: - matrix_mautrix_wsproxy_restart_necessary: >- + matrix_bridge_mautrix_wsproxy_restart_necessary: >- {{ - matrix_mautrix_wsproxy_migration_requires_restart | default(false) - or matrix_mautrix_wsproxy_support_files_result.changed | default(false) - or matrix_mautrix_wsproxy_config_result.changed | default(false) - or matrix_mautrix_wsproxy_registration_androidsms_result.changed | default(false) - or matrix_mautrix_wsproxy_registration_imessage_result.changed | default(false) - or matrix_mautrix_wsproxy_systemd_service_result.changed | default(false) - or matrix_mautrix_wsproxy_container_image_pull_result.changed | default(false) + matrix_bridge_mautrix_wsproxy_migration_requires_restart | default(false) + or matrix_bridge_mautrix_wsproxy_support_files_result.changed | default(false) + or matrix_bridge_mautrix_wsproxy_config_result.changed | default(false) + or matrix_bridge_mautrix_wsproxy_registration_androidsms_result.changed | default(false) + or matrix_bridge_mautrix_wsproxy_registration_imessage_result.changed | default(false) + or matrix_bridge_mautrix_wsproxy_systemd_service_result.changed | default(false) + or matrix_bridge_mautrix_wsproxy_container_image_pull_result.changed | default(false) }} - name: Ensure systemd reloaded after matrix-mautrix-wsproxy.service installation ansible.builtin.service: daemon_reload: true - when: "matrix_mautrix_wsproxy_systemd_service_result.changed" + when: "matrix_bridge_mautrix_wsproxy_systemd_service_result.changed" - name: Ensure matrix-mautrix-wsproxy.service restarted, if necessary ansible.builtin.service: name: "matrix-mautrix-wsproxy.service" state: restarted - when: "matrix_mautrix_wsproxy_migration_requires_restart|bool" + when: "matrix_bridge_mautrix_wsproxy_migration_requires_restart|bool" - name: Ensure matrix-mautrix-wsproxy-syncproxy.service installed ansible.builtin.template: src: "{{ role_path }}/templates/systemd/matrix-mautrix-wsproxy-syncproxy.service.j2" dest: "{{ devture_systemd_docker_base_systemd_path }}/matrix-mautrix-wsproxy-syncproxy.service" mode: '0644' - register: matrix_mautrix_wsproxy_syncproxy_systemd_service_result + register: matrix_bridge_mautrix_wsproxy_syncproxy_systemd_service_result - name: Determine whether Mautrix wsproxy syncproxy needs a restart ansible.builtin.set_fact: - matrix_mautrix_wsproxy_syncproxy_restart_necessary: >- + matrix_bridge_mautrix_wsproxy_syncproxy_restart_necessary: >- {{ - matrix_mautrix_wsproxy_syncproxy_migration_requires_restart | default(false) - or matrix_mautrix_wsproxy_syncproxy_systemd_service_result.changed | default(false) - or matrix_mautrix_wsproxy_syncproxy_container_image_pull_result.changed | default(false) + matrix_bridge_mautrix_wsproxy_syncproxy_migration_requires_restart | default(false) + or matrix_bridge_mautrix_wsproxy_syncproxy_systemd_service_result.changed | default(false) + or matrix_bridge_mautrix_wsproxy_syncproxy_container_image_pull_result.changed | default(false) }} - name: Ensure systemd reloaded after matrix-mautrix-wsproxy-syncproxy.service installation ansible.builtin.service: daemon_reload: true - when: "matrix_mautrix_wsproxy_syncproxy_systemd_service_result.changed" + when: "matrix_bridge_mautrix_wsproxy_syncproxy_systemd_service_result.changed" - name: Ensure matrix-mautrix-wsproxy-syncproxy.service restarted, if necessary ansible.builtin.service: name: "matrix-mautrix-wsproxy-syncproxy.service" state: restarted - when: "matrix_mautrix_wsproxy_syncproxy_migration_requires_restart|bool" + when: "matrix_bridge_mautrix_wsproxy_syncproxy_migration_requires_restart|bool" diff --git a/roles/custom/matrix-bridge-mautrix-wsproxy/tasks/setup_uninstall.yml b/roles/custom/matrix-bridge-mautrix-wsproxy/tasks/setup_uninstall.yml index 0326fcb96..12572d3a8 100644 --- a/roles/custom/matrix-bridge-mautrix-wsproxy/tasks/setup_uninstall.yml +++ b/roles/custom/matrix-bridge-mautrix-wsproxy/tasks/setup_uninstall.yml @@ -7,45 +7,45 @@ - name: Check existence of matrix-mautrix-wsproxy service ansible.builtin.stat: path: "{{ devture_systemd_docker_base_systemd_path }}/matrix-mautrix-wsproxy.service" - register: matrix_mautrix_wsproxy_service_stat + register: matrix_bridge_mautrix_wsproxy_service_stat - name: Ensure matrix-mautrix-wsproxy is stopped ansible.builtin.service: name: matrix-mautrix-wsproxy state: stopped daemon_reload: true - when: "matrix_mautrix_wsproxy_service_stat.stat.exists" + when: "matrix_bridge_mautrix_wsproxy_service_stat.stat.exists" - name: Ensure matrix-mautrix-wsproxy.service doesn't exist ansible.builtin.file: path: "{{ devture_systemd_docker_base_systemd_path }}/matrix-mautrix-wsproxy.service" state: absent - when: "matrix_mautrix_wsproxy_service_stat.stat.exists" + when: "matrix_bridge_mautrix_wsproxy_service_stat.stat.exists" - name: Ensure systemd reloaded after matrix-mautrix-wsproxy.service removal ansible.builtin.service: daemon_reload: true - when: "matrix_mautrix_wsproxy_service_stat.stat.exists" + when: "matrix_bridge_mautrix_wsproxy_service_stat.stat.exists" - name: Check existence of matrix-mautrix-wsproxy-syncproxy service ansible.builtin.stat: path: "{{ devture_systemd_docker_base_systemd_path }}/matrix-mautrix-wsproxy-syncproxy.service" - register: matrix_mautrix_wsproxy_syncproxy_service_stat + register: matrix_bridge_mautrix_wsproxy_syncproxy_service_stat - name: Ensure matrix-mautrix-wsproxy-syncproxy is stopped ansible.builtin.service: name: matrix-mautrix-wsproxy-syncproxy state: stopped daemon_reload: true - when: "matrix_mautrix_wsproxy_syncproxy_service_stat.stat.exists" + when: "matrix_bridge_mautrix_wsproxy_syncproxy_service_stat.stat.exists" - name: Ensure matrix-mautrix-wsproxy-syncproxy.service doesn't exist ansible.builtin.file: path: "{{ devture_systemd_docker_base_systemd_path }}/matrix-mautrix-wsproxy-syncproxy.service" state: absent - when: "matrix_mautrix_wsproxy_syncproxy_service_stat.stat.exists" + when: "matrix_bridge_mautrix_wsproxy_syncproxy_service_stat.stat.exists" - name: Ensure systemd reloaded after matrix-mautrix-wsproxy-syncproxy.service removal ansible.builtin.service: daemon_reload: true - when: "matrix_mautrix_wsproxy_syncproxy_service_stat.stat.exists" + when: "matrix_bridge_mautrix_wsproxy_syncproxy_service_stat.stat.exists" diff --git a/roles/custom/matrix-bridge-mautrix-wsproxy/tasks/validate_config.yml b/roles/custom/matrix-bridge-mautrix-wsproxy/tasks/validate_config.yml index fb58cf455..b3f6c8a46 100644 --- a/roles/custom/matrix-bridge-mautrix-wsproxy/tasks/validate_config.yml +++ b/roles/custom/matrix-bridge-mautrix-wsproxy/tasks/validate_config.yml @@ -12,15 +12,15 @@ Please rename the variable (`{{ item.old }}` -> `{{ item.new }}`) on your configuration file (vars.yml). when: "lookup('ansible.builtin.varnames', ('^' + item.old + '$'), wantlist=True) | length > 0" with_items: - - {'old': 'matrix_mautrix_wsproxy_docker_image', 'new': 'matrix_mautrix_wsproxy_container_image'} - - {'old': 'matrix_mautrix_wsproxy_docker_image_force_pull', 'new': 'matrix_mautrix_wsproxy_container_image_force_pull'} - - {'old': 'matrix_mautrix_wsproxy_docker_image_registry_prefix', 'new': 'matrix_mautrix_wsproxy_container_image_registry_prefix'} - - {'old': 'matrix_mautrix_wsproxy_docker_image_registry_prefix_upstream', 'new': 'matrix_mautrix_wsproxy_container_image_registry_prefix_upstream'} - - {'old': 'matrix_mautrix_wsproxy_docker_image_registry_prefix_upstream_default', 'new': 'matrix_mautrix_wsproxy_container_image_registry_prefix_upstream_default'} - - {'old': 'matrix_mautrix_wsproxy_syncproxy_docker_image', 'new': 'matrix_mautrix_wsproxy_syncproxy_container_image'} - - {'old': 'matrix_mautrix_wsproxy_syncproxy_docker_image_force_pull', 'new': 'matrix_mautrix_wsproxy_syncproxy_container_image_force_pull'} - - {'old': 'matrix_mautrix_wsproxy_container_image_force_pull', 'new': ' (the new community.docker.docker_image_pull module handles this natively)'} - - {'old': 'matrix_mautrix_wsproxy_syncproxy_container_image_force_pull', 'new': ' (the new community.docker.docker_image_pull module handles this natively)'} + - {'old': 'matrix_bridge_mautrix_wsproxy_docker_image', 'new': 'matrix_bridge_mautrix_wsproxy_container_image'} + - {'old': 'matrix_bridge_mautrix_wsproxy_docker_image_force_pull', 'new': 'matrix_bridge_mautrix_wsproxy_container_image_force_pull'} + - {'old': 'matrix_bridge_mautrix_wsproxy_docker_image_registry_prefix', 'new': 'matrix_bridge_mautrix_wsproxy_container_image_registry_prefix'} + - {'old': 'matrix_bridge_mautrix_wsproxy_docker_image_registry_prefix_upstream', 'new': 'matrix_bridge_mautrix_wsproxy_container_image_registry_prefix_upstream'} + - {'old': 'matrix_bridge_mautrix_wsproxy_docker_image_registry_prefix_upstream_default', 'new': 'matrix_bridge_mautrix_wsproxy_container_image_registry_prefix_upstream_default'} + - {'old': 'matrix_bridge_mautrix_wsproxy_syncproxy_docker_image', 'new': 'matrix_bridge_mautrix_wsproxy_syncproxy_container_image'} + - {'old': 'matrix_bridge_mautrix_wsproxy_syncproxy_docker_image_force_pull', 'new': 'matrix_bridge_mautrix_wsproxy_syncproxy_container_image_force_pull'} + - {'old': 'matrix_bridge_mautrix_wsproxy_container_image_force_pull', 'new': ' (the new community.docker.docker_image_pull module handles this natively)'} + - {'old': 'matrix_bridge_mautrix_wsproxy_syncproxy_container_image_force_pull', 'new': ' (the new community.docker.docker_image_pull module handles this natively)'} - name: Fail if required settings not defined @@ -29,12 +29,12 @@ You need to define a required configuration setting (`{{ item }}`). when: "lookup('vars', item, default='') == ''" with_items: - - "matrix_mautrix_androidsms_appservice_token" - - "matrix_mautrix_androidsms_homeserver_token" - - "matrix_mautrix_imessage_appservice_token" - - "matrix_mautrix_imessage_homeserver_token" - - "matrix_mautrix_wsproxy_homeserver_address" - - "matrix_mautrix_wsproxy_syncproxy_shared_secret" - - "matrix_mautrix_wsproxy_syncproxy_homeserver_url" - - "matrix_mautrix_wsproxy_syncproxy_database_hostname" - - "matrix_mautrix_wsproxy_syncproxy_database_password" + - "matrix_bridge_mautrix_wsproxy_androidsms_appservice_token" + - "matrix_bridge_mautrix_wsproxy_androidsms_homeserver_token" + - "matrix_bridge_mautrix_wsproxy_imessage_appservice_token" + - "matrix_bridge_mautrix_wsproxy_imessage_homeserver_token" + - "matrix_bridge_mautrix_wsproxy_homeserver_address" + - "matrix_bridge_mautrix_wsproxy_syncproxy_shared_secret" + - "matrix_bridge_mautrix_wsproxy_syncproxy_homeserver_url" + - "matrix_bridge_mautrix_wsproxy_syncproxy_database_hostname" + - "matrix_bridge_mautrix_wsproxy_syncproxy_database_password" diff --git a/roles/custom/matrix-bridge-mautrix-wsproxy/templates/config.yaml.j2 b/roles/custom/matrix-bridge-mautrix-wsproxy/templates/config.yaml.j2 index b0eae9f68..0f07636db 100644 --- a/roles/custom/matrix-bridge-mautrix-wsproxy/templates/config.yaml.j2 +++ b/roles/custom/matrix-bridge-mautrix-wsproxy/templates/config.yaml.j2 @@ -7,14 +7,14 @@ SPDX-License-Identifier: AGPL-3.0-or-later listen_address: 0.0.0.0:29331 appservices: - id: androidsms - as: {{ matrix_mautrix_androidsms_appservice_token | to_json }} - hs: {{ matrix_mautrix_androidsms_homeserver_token | to_json }} + as: {{ matrix_bridge_mautrix_wsproxy_androidsms_appservice_token | to_json }} + hs: {{ matrix_bridge_mautrix_wsproxy_androidsms_homeserver_token | to_json }} - id: imessage - as: {{ matrix_mautrix_imessage_appservice_token | to_json }} - hs: {{ matrix_mautrix_imessage_homeserver_token | to_json }} + as: {{ matrix_bridge_mautrix_wsproxy_imessage_appservice_token | to_json }} + hs: {{ matrix_bridge_mautrix_wsproxy_imessage_homeserver_token | to_json }} sync_proxy: # The URL that mautrix-wsproxy can use to reach mautrix-syncproxy - url: {{ matrix_mautrix_wsproxy_syncproxy_appservice_address | to_json }} + url: {{ matrix_bridge_mautrix_wsproxy_syncproxy_appservice_address | to_json }} # The URL that mautrix-syncproxy can use to reach mautrix-wsproxy - wsproxy_url: {{ matrix_mautrix_wsproxy_appservice_address | to_json }} - shared_secret: {{ matrix_mautrix_wsproxy_syncproxy_shared_secret | to_json }} + wsproxy_url: {{ matrix_bridge_mautrix_wsproxy_appservice_address | to_json }} + shared_secret: {{ matrix_bridge_mautrix_wsproxy_syncproxy_shared_secret | to_json }} diff --git a/roles/custom/matrix-bridge-mautrix-wsproxy/templates/syncproxy-env.j2 b/roles/custom/matrix-bridge-mautrix-wsproxy/templates/syncproxy-env.j2 index 45ff0d9b6..277f8303e 100644 --- a/roles/custom/matrix-bridge-mautrix-wsproxy/templates/syncproxy-env.j2 +++ b/roles/custom/matrix-bridge-mautrix-wsproxy/templates/syncproxy-env.j2 @@ -5,6 +5,6 @@ SPDX-FileCopyrightText: 2024 Slavi Pantaleev SPDX-License-Identifier: AGPL-3.0-or-later #} -DATABASE_URL={{ matrix_mautrix_signal_wsproxy_syncproxy_connection_string }} -HOMESERVER_URL={{ matrix_mautrix_wsproxy_syncproxy_homeserver_url }} -SHARED_SECRET={{ matrix_mautrix_wsproxy_syncproxy_shared_secret }} +DATABASE_URL={{ matrix_bridge_mautrix_wsproxy_syncproxy_connection_string }} +HOMESERVER_URL={{ matrix_bridge_mautrix_wsproxy_syncproxy_homeserver_url }} +SHARED_SECRET={{ matrix_bridge_mautrix_wsproxy_syncproxy_shared_secret }} diff --git a/roles/custom/matrix-bridge-mautrix-wsproxy/templates/systemd/matrix-mautrix-wsproxy-syncproxy.service.j2 b/roles/custom/matrix-bridge-mautrix-wsproxy/templates/systemd/matrix-mautrix-wsproxy-syncproxy.service.j2 index 54673bd9b..32f60703c 100644 --- a/roles/custom/matrix-bridge-mautrix-wsproxy/templates/systemd/matrix-mautrix-wsproxy-syncproxy.service.j2 +++ b/roles/custom/matrix-bridge-mautrix-wsproxy/templates/systemd/matrix-mautrix-wsproxy-syncproxy.service.j2 @@ -1,11 +1,11 @@ #jinja2: lstrip_blocks: True [Unit] Description=Matrix Mautrix wsproxy syncproxy -{% for service in matrix_mautrix_wsproxy_syncproxy_systemd_required_services_list %} +{% for service in matrix_bridge_mautrix_wsproxy_syncproxy_systemd_required_services_list %} Requires={{ service }} After={{ service }} {% endfor %} -{% for service in matrix_mautrix_wsproxy_syncproxy_systemd_wanted_services_list %} +{% for service in matrix_bridge_mautrix_wsproxy_syncproxy_systemd_wanted_services_list %} Wants={{ service }} {% endfor %} DefaultDependencies=no @@ -22,15 +22,15 @@ ExecStartPre={{ devture_systemd_docker_base_host_command_docker }} create \ --log-driver=none \ --user={{ matrix_user_uid }}:{{ matrix_user_gid }} \ --cap-drop=ALL \ - --network={{ matrix_mautrix_wsproxy_container_network }} \ - --env-file={{ matrix_mautrix_wsproxy_base_path }}/syncproxy-env \ - {% for arg in matrix_mautrix_wsproxy_syncproxy_container_extra_arguments %} + --network={{ matrix_bridge_mautrix_wsproxy_container_network }} \ + --env-file={{ matrix_bridge_mautrix_wsproxy_base_path }}/syncproxy-env \ + {% for arg in matrix_bridge_mautrix_wsproxy_syncproxy_container_extra_arguments %} {{ arg }} \ {% endfor %} - {{ matrix_mautrix_wsproxy_syncproxy_container_image }} + {{ matrix_bridge_mautrix_wsproxy_syncproxy_container_image }} -{% if matrix_mautrix_wsproxy_container_network != 'host' %} -{% for network in matrix_mautrix_wsproxy_container_additional_networks %} +{% if matrix_bridge_mautrix_wsproxy_container_network != 'host' %} +{% for network in matrix_bridge_mautrix_wsproxy_container_additional_networks %} ExecStartPre={{ devture_systemd_docker_base_host_command_docker }} network connect {{ network }} matrix-mautrix-wsproxy-syncproxy {% endfor %} {% endif %} diff --git a/roles/custom/matrix-bridge-mautrix-wsproxy/templates/systemd/matrix-mautrix-wsproxy.service.j2 b/roles/custom/matrix-bridge-mautrix-wsproxy/templates/systemd/matrix-mautrix-wsproxy.service.j2 index fb5707414..e1a91cebb 100644 --- a/roles/custom/matrix-bridge-mautrix-wsproxy/templates/systemd/matrix-mautrix-wsproxy.service.j2 +++ b/roles/custom/matrix-bridge-mautrix-wsproxy/templates/systemd/matrix-mautrix-wsproxy.service.j2 @@ -1,11 +1,11 @@ #jinja2: lstrip_blocks: True [Unit] Description=Matrix Mautrix wsproxy bridge -{% for service in matrix_mautrix_wsproxy_systemd_required_services_list %} +{% for service in matrix_bridge_mautrix_wsproxy_systemd_required_services_list %} Requires={{ service }} After={{ service }} {% endfor %} -{% for service in matrix_mautrix_wsproxy_systemd_wanted_services_list %} +{% for service in matrix_bridge_mautrix_wsproxy_systemd_wanted_services_list %} Wants={{ service }} {% endfor %} DefaultDependencies=no @@ -20,20 +20,20 @@ ExecStartPre={{ devture_systemd_docker_base_host_command_docker }} create --rm - --log-driver=none \ --user={{ matrix_user_uid }}:{{ matrix_user_gid }} \ --cap-drop=ALL \ - --network={{ matrix_mautrix_wsproxy_container_network }} \ - {% if matrix_mautrix_wsproxy_bind_port %} - -p {{ matrix_mautrix_wsproxy_port }}:29331 \ + --network={{ matrix_bridge_mautrix_wsproxy_container_network }} \ + {% if matrix_bridge_mautrix_wsproxy_bind_port %} + -p {{ matrix_bridge_mautrix_wsproxy_port }}:29331 \ {% endif %} - --mount type=bind,src={{ matrix_mautrix_wsproxy_config_path }},dst=/data \ - --label-file={{ matrix_mautrix_wsproxy_base_path }}/wsproxy-labels \ - {% for arg in matrix_mautrix_wsproxy_container_extra_arguments %} + --mount type=bind,src={{ matrix_bridge_mautrix_wsproxy_config_path }},dst=/data \ + --label-file={{ matrix_bridge_mautrix_wsproxy_base_path }}/wsproxy-labels \ + {% for arg in matrix_bridge_mautrix_wsproxy_container_extra_arguments %} {{ arg }} \ {% endfor %} - {{ matrix_mautrix_wsproxy_container_image }} \ + {{ matrix_bridge_mautrix_wsproxy_container_image }} \ /usr/bin/mautrix-wsproxy -config /data/config.yaml -{% if matrix_mautrix_wsproxy_container_network != 'host' %} -{% for network in matrix_mautrix_wsproxy_container_additional_networks %} +{% if matrix_bridge_mautrix_wsproxy_container_network != 'host' %} +{% for network in matrix_bridge_mautrix_wsproxy_container_additional_networks %} ExecStartPre={{ devture_systemd_docker_base_host_command_docker }} network connect {{ network }} matrix-mautrix-wsproxy {% endfor %} {% endif %} diff --git a/roles/custom/matrix-bridge-mautrix-wsproxy/templates/wsproxy-labels.j2 b/roles/custom/matrix-bridge-mautrix-wsproxy/templates/wsproxy-labels.j2 index 06a879b9c..5f0c94322 100644 --- a/roles/custom/matrix-bridge-mautrix-wsproxy/templates/wsproxy-labels.j2 +++ b/roles/custom/matrix-bridge-mautrix-wsproxy/templates/wsproxy-labels.j2 @@ -4,37 +4,37 @@ SPDX-FileCopyrightText: 2023 Johan Swetzén SPDX-License-Identifier: AGPL-3.0-or-later #} -{% if matrix_mautrix_wsproxy_container_labels_traefik_enabled %} +{% if matrix_bridge_mautrix_wsproxy_container_labels_traefik_enabled %} traefik.enable=true -{% if matrix_mautrix_wsproxy_container_labels_traefik_docker_network %} -traefik.docker.network={{ matrix_mautrix_wsproxy_container_labels_traefik_docker_network }} +{% if matrix_bridge_mautrix_wsproxy_container_labels_traefik_docker_network %} +traefik.docker.network={{ matrix_bridge_mautrix_wsproxy_container_labels_traefik_docker_network }} {% endif %} {% set middlewares = [] %} -{% if matrix_mautrix_wsproxy_container_labels_traefik_additional_response_headers.keys() | length > 0 %} -{% for name, value in matrix_mautrix_wsproxy_container_labels_traefik_additional_response_headers.items() %} +{% if matrix_bridge_mautrix_wsproxy_container_labels_traefik_additional_response_headers.keys() | length > 0 %} +{% for name, value in matrix_bridge_mautrix_wsproxy_container_labels_traefik_additional_response_headers.items() %} traefik.http.middlewares.matrix-mautrix-wsproxy-add-headers.headers.customresponseheaders.{{ name }}={{ value }} {% endfor %} {% set middlewares = middlewares + ['matrix-mautrix-wsproxy-add-headers'] %} {% endif %} -traefik.http.routers.matrix-mautrix-wsproxy.rule={{ matrix_mautrix_wsproxy_container_labels_traefik_rule }} -{% if matrix_mautrix_wsproxy_container_labels_traefik_priority | int > 0 %} -traefik.http.routers.matrix-mautrix-wsproxy.priority={{ matrix_mautrix_wsproxy_container_labels_traefik_priority }} +traefik.http.routers.matrix-mautrix-wsproxy.rule={{ matrix_bridge_mautrix_wsproxy_container_labels_traefik_rule }} +{% if matrix_bridge_mautrix_wsproxy_container_labels_traefik_priority | int > 0 %} +traefik.http.routers.matrix-mautrix-wsproxy.priority={{ matrix_bridge_mautrix_wsproxy_container_labels_traefik_priority }} {% endif %} traefik.http.routers.matrix-mautrix-wsproxy.service=matrix-mautrix-wsproxy {% if middlewares | length > 0 %} traefik.http.routers.matrix-mautrix-wsproxy.middlewares={{ middlewares | join(',') }} {% endif %} -traefik.http.routers.matrix-mautrix-wsproxy.entrypoints={{ matrix_mautrix_wsproxy_container_labels_traefik_entrypoints }} -traefik.http.routers.matrix-mautrix-wsproxy.tls={{ matrix_mautrix_wsproxy_container_labels_traefik_tls | to_json }} -{% if matrix_mautrix_wsproxy_container_labels_traefik_tls %} -traefik.http.routers.matrix-mautrix-wsproxy.tls.certResolver={{ matrix_mautrix_wsproxy_container_labels_traefik_tls_certResolver }} +traefik.http.routers.matrix-mautrix-wsproxy.entrypoints={{ matrix_bridge_mautrix_wsproxy_container_labels_traefik_entrypoints }} +traefik.http.routers.matrix-mautrix-wsproxy.tls={{ matrix_bridge_mautrix_wsproxy_container_labels_traefik_tls | to_json }} +{% if matrix_bridge_mautrix_wsproxy_container_labels_traefik_tls %} +traefik.http.routers.matrix-mautrix-wsproxy.tls.certResolver={{ matrix_bridge_mautrix_wsproxy_container_labels_traefik_tls_certResolver }} {% endif %} -traefik.http.services.matrix-mautrix-wsproxy.loadbalancer.server.port={{ matrix_mautrix_wsproxy_port }} +traefik.http.services.matrix-mautrix-wsproxy.loadbalancer.server.port={{ matrix_bridge_mautrix_wsproxy_port }} {% endif %} -{{ matrix_mautrix_wsproxy_container_labels_additional_labels }} +{{ matrix_bridge_mautrix_wsproxy_container_labels_additional_labels }}