Compare commits

...

3 Commits

Author SHA1 Message Date
ignyx
21ad191e9b
fix: wrong variable in mautrix-meta config validation
Co-authored-by: Slavi Pantaleev <slavi@devture.com>
2024-10-20 21:48:47 +02:00
Paul ALNET
564b3cf169 feat: serve mautrix bridgev2 wellknown file 2024-10-20 21:41:08 +02:00
Paul ALNET
c57c9f68c0 fix: add missing path prefix for mautrix-manager compatibility 2024-10-16 11:13:30 +02:00
8 changed files with 102 additions and 7 deletions

View File

@ -5581,6 +5581,15 @@ matrix_static_files_file_matrix_client_property_m_tile_server_map_style_url: "{{
matrix_static_files_file_matrix_server_property_m_server: "{{ matrix_server_fqn_matrix_federation }}:{{ matrix_federation_public_port }}"
# mautrix-manager auto-configuration disabled by default
matrix_static_files_file_matrix_mautrix_enabled: false
matrix_static_files_file_matrix_mautrix_property_fi_mau_bridges:
- "https://bridges.example.com/signal"
# TODO populate with enabled bridges
matrix_static_files_file_matrix_mautrix_property_fi_mau_external_bridge_servers:
[]
matrix_static_files_scheme: "{{ 'https' if matrix_playbook_ssl_enabled else 'http' }}"
matrix_static_files_self_check_hostname_matrix: "{{ matrix_server_fqn_matrix }}"

View File

@ -59,9 +59,8 @@ matrix_mautrix_meta_messenger_container_labels_metrics_middleware_basic_auth_use
matrix_mautrix_meta_messenger_container_labels_bridgev2_enabled: "{{ matrix_mautrix_meta_messenger_appservice_bridgev2_enabled }}"
matrix_mautrix_meta_messenger_container_labels_bridgev2_traefik_hostname: ""
# Following two variables should be RegEx-escaped, see https://doc.traefik.io/traefik/middlewares/http/replacepathregex/
matrix_mautrix_meta_messenger_container_labels_bridgev2_traefik_path_external: "/_matrix/{{ matrix_mautrix_meta_messenger_identifier }}/provision"
matrix_mautrix_meta_messenger_container_labels_bridgev2_traefik_path_internal: "/_matrix/provision"
matrix_mautrix_meta_messenger_container_labels_bridgev2_traefik_rule: "Host(`{{ matrix_mautrix_meta_messenger_container_labels_bridgev2_traefik_hostname }}`) && PathPrefix(`{{ matrix_mautrix_meta_messenger_container_labels_bridgev2_traefik_path_external }}`)"
matrix_mautrix_meta_messenger_container_labels_bridgev2_traefik_stripprefix: "/_matrix/{{ matrix_mautrix_meta_messenger_identifier }}"
matrix_mautrix_meta_messenger_container_labels_bridgev2_traefik_rule: "Host(`{{ matrix_mautrix_meta_messenger_container_labels_bridgev2_traefik_hostname }}`) && PathPrefix(`{{ matrix_mautrix_meta_messenger_container_labels_bridgev2_traefik_stripprefix }}`)"
matrix_mautrix_meta_messenger_container_labels_bridgev2_traefik_priority: 0
matrix_mautrix_meta_messenger_container_labels_bridgev2_traefik_entrypoints: "{{ matrix_mautrix_meta_messenger_container_labels_traefik_entrypoints }}"
matrix_mautrix_meta_messenger_container_labels_bridgev2_traefik_tls: "{{ matrix_mautrix_meta_messenger_container_labels_metrics_traefik_entrypoints != 'web' }}"

View File

@ -8,7 +8,7 @@
with_items:
- {'name': 'matrix_mautrix_meta_messenger_metrics_proxying_hostname', when: "{{ matrix_mautrix_meta_messenger_metrics_proxying_enabled }}"}
- {'name': 'matrix_mautrix_meta_messenger_metrics_proxying_path_prefix', when: "{{ matrix_mautrix_meta_messenger_metrics_proxying_enabled }}"}
- {'name': 'matrix_mautrix_meta_messenger_container_labels_bridgev2_traefik_hostname', when: "{{ matrix_mautrix_meta_messenger_metrics_proxying_enabled }}"}
- {'name': 'matrix_mautrix_meta_messenger_container_labels_bridgev2_traefik_hostname', when: "{{ matrix_mautrix_meta_messenger_container_labels_bridgev2_enabled }}"}
- {'name': 'matrix_mautrix_meta_messenger_appservice_token', when: true}
- {'name': 'matrix_mautrix_meta_messenger_homeserver_token', when: true}
- {'name': 'matrix_mautrix_meta_messenger_container_network', when: true}

View File

@ -50,9 +50,8 @@ traefik.http.routers.{{ matrix_mautrix_meta_messenger_identifier }}-metrics.tls.
# #
############################################################
traefik.http.middlewares.{{ matrix_mautrix_meta_messenger_identifier }}-bridgev2-replacepathregex.replacepathregex.regex=^{{ matrix_mautrix_meta_messenger_container_labels_bridgev2_traefik_path_external }}/(.*)
traefik.http.middlewares.{{ matrix_mautrix_meta_messenger_identifier }}-bridgev2-replacepathregex.replacepathregex.replacement={{ matrix_mautrix_meta_messenger_container_labels_bridgev2_traefik_path_internal }}/$1
traefik.http.routers.{{ matrix_mautrix_meta_messenger_identifier }}-bridgev2.middlewares={{ matrix_mautrix_meta_messenger_identifier }}-bridgev2-replacepathregex
traefik.http.middlewares.{{ matrix_mautrix_meta_messenger_identifier }}-bridgev2-stripprefix.stripprefix.prefixes={{ matrix_mautrix_meta_messenger_container_labels_bridgev2_traefik_stripprefix }}
traefik.http.routers.{{ matrix_mautrix_meta_messenger_identifier }}-bridgev2.middlewares={{ matrix_mautrix_meta_messenger_identifier }}-bridgev2-stripprefix
traefik.http.routers.{{ matrix_mautrix_meta_messenger_identifier }}-bridgev2.rule={{ matrix_mautrix_meta_messenger_container_labels_bridgev2_traefik_rule }}

View File

@ -332,6 +332,65 @@ matrix_static_files_file_matrix_support_configuration: "{{ matrix_static_files_f
# #
########################################################################
########################################################################
# #
# Related to /.well-known/matrix/mautrix #
# #
########################################################################
# Controls whether a `/.well-known/matrix/mautrix` file is generated and used at all.
# For details about this file, see mautrix/manager auto-configuration section : https://github.com/mautrix/manager#auto-configuration
#
# This is not enabled by default, as for it to be useful, other information is necessary.
# See `matrix_static_files_file_matrix_mautrix_property_fi_mau_bridges`, `matrix_static_files_file_matrix_mautrix_property_fi_mau_external_bridge_servers`, etc.
matrix_static_files_file_matrix_mautrix_enabled: false
# Controls the fi.mau.bridges property in the /.well-known/matrix/mautrix file
# It indexes local bridges implementing the bridgev2 API
# Example entry : https://bridges.example.com/signal
matrix_static_files_file_matrix_mautrix_property_fi_mau_bridges: []
# Controls the fi.mau.external_bridge_servers property in the /.well-known/matrix/mautrix file
# It indexes remote servers with bridges implementing the bridgev2 API
# Example entry : anotherserver.example.org
matrix_static_files_file_matrix_mautrix_property_fi_mau_external_bridge_servers:
[]
# Default /.well-known/matrix/mautrix 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_static_files_file_matrix_mautrix_configuration_extension_json`)
# or completely replace this variable with your own template.
matrix_static_files_file_matrix_mautrix_configuration_json: "{{ lookup('template', 'templates/public/.well-known/matrix/mautrix.j2') }}"
# Your custom JSON configuration for /.well-known/matrix/mautrix should go to `matrix_static_files_file_matrix_mautrix_configuration_extension_json`.
# This configuration extends the default starting configuration (`matrix_static_files_file_matrix_mautrix_configuration_extension_json`).
#
# 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_static_files_file_matrix_mautrix_configuration_json`.
#
# Example configuration extension follows:
#
# matrix_static_files_file_matrix_mautrix_configuration_extension_json: |
# {
# "m.another": "value",
# "m.yet_another": 3
# }
matrix_static_files_file_matrix_mautrix_configuration_extension_json: "{}"
matrix_static_files_file_matrix_mautrix_configuration_extension: "{{ matrix_static_files_file_matrix_mautrix_configuration_extension_json | from_json if matrix_static_files_file_matrix_mautrix_configuration_extension_json | from_json is mapping else {} }}"
# Holds the final /.well-known/matrix/mautrix configuration (a combination of the default and its extension).
# You most likely don't need to touch this variable. Instead, see `matrix_static_files_file_matrix_mautrix_configuration_json` or `matrix_static_files_file_matrix_mautrix_configuration_extension_json`.
matrix_static_files_file_matrix_mautrix_configuration: "{{ matrix_static_files_file_matrix_mautrix_configuration_json | combine(matrix_static_files_file_matrix_mautrix_configuration_extension, recursive=True) }}"
########################################################################
# #
# /Related to /.well-known/matrix/mautrix #
# #
########################################################################
########################################################################
# #

View File

@ -52,6 +52,10 @@
dest: "{{ matrix_static_files_public_well_known_matrix_path }}/support"
when: "{{ matrix_static_files_file_matrix_support_enabled }}"
- content: "{{ matrix_static_files_file_matrix_mautrix_configuration | to_nice_json }}"
dest: "{{ matrix_static_files_public_well_known_matrix_path }}/mautrix"
when: "{{ matrix_static_files_file_matrix_mautrix_enabled }}"
# This one will not be deleted if `matrix_static_files_file_index_html_enabled` flips to `false`.
# See the comment for `matrix_static_files_file_index_html_enabled` to learn why.
- content: "{{ matrix_static_files_file_index_html_template }}"
@ -70,6 +74,12 @@
state: absent
when: "not matrix_static_files_file_matrix_support_enabled | bool"
- name: Ensure /.well-known/matrix/mautrix file deleted if not enabled
ansible.builtin.file:
path: "{{ matrix_static_files_public_well_known_matrix_path }}/mautrix"
state: absent
when: "not matrix_static_files_file_matrix_mautrix_enabled | bool"
- name: Ensure matrix-static-files container image is pulled
community.docker.docker_image:
name: "{{ matrix_static_files_container_image }}"

View File

@ -24,6 +24,21 @@
ansible.builtin.set_fact:
well_known_file_checks: "{{ well_known_file_checks + [well_known_file_check_matrix_server] }}"
- when: matrix_static_files_file_matrix_mautrix_enabled | bool
block:
- name: Prepare /.well-known/matrix/mautrix to well-known files to check, if enabled
ansible.builtin.set_fact:
well_known_file_check_matrix_mautrix:
path: /.well-known/matrix/mautrix
purpose: Mautrix bridge discovery
cors: true
follow_redirects: safe
validate_certs: "{{ matrix_static_files_self_check_validate_certificates }}"
- name: Inject /.well-known/matrix/mautrix to well-known files to check, if enabled
ansible.builtin.set_fact:
well_known_file_checks: "{{ well_known_file_checks + [well_known_file_check_matrix_mautrix] }}"
- name: Perform well-known checks
ansible.builtin.include_tasks: "{{ role_path }}/tasks/self_check_well_known_file.yml"
with_items: "{{ well_known_file_checks }}"

View File

@ -0,0 +1,4 @@
{
"fi.mau.bridges": {{ matrix_static_files_file_matrix_mautrix_property_fi_mau_bridges|to_json }},
"fi.mau.external_bridge_servers": {{ matrix_static_files_file_matrix_mautrix_property_fi_mau_external_bridge_servers|to_json }}
}