From 1dfe21944fc83c8f2c2afe25756b2e9d475c714d Mon Sep 17 00:00:00 2001 From: Slavi Pantaleev Date: Thu, 23 Dec 2021 16:28:34 +0200 Subject: [PATCH] Make matrix_homeserver_implementation influence matrix_IMPLEMENTATION_enabled, not the other way around Doing this seems more reasonable and simpler. --- examples/vars.yml | 4 ++++ group_vars/matrix_servers | 15 ++++----------- roles/matrix-base/defaults/main.yml | 12 +++++++----- roles/matrix-base/tasks/sanity_check.yml | 12 +++--------- roles/matrix-dendrite/defaults/main.yml | 2 +- 5 files changed, 19 insertions(+), 26 deletions(-) diff --git a/examples/vars.yml b/examples/vars.yml index f6c86be9f..9623ad392 100644 --- a/examples/vars.yml +++ b/examples/vars.yml @@ -10,6 +10,10 @@ # Example value: example.com matrix_domain: YOUR_BARE_DOMAIN_NAME_HERE +# The Matrix homeserver software to install. +# See `roles/matrix-base/defaults/main.yml` for valid options. +matrix_homeserver_implementation: synapse + # This is something which is provided to Let's Encrypt when retrieving SSL certificates for domains. # # In case SSL renewal fails at some point, you'll also get an email notification there. diff --git a/group_vars/matrix_servers b/group_vars/matrix_servers index 9c011b4e4..3c2161dc9 100755 --- a/group_vars/matrix_servers +++ b/group_vars/matrix_servers @@ -17,17 +17,6 @@ matrix_container_global_registry_prefix: "docker.io/" # ###################################################################### -matrix_homeserver_enabled_implementations_list: | - {{ - ( - (['synapse'] if matrix_synapse_enabled else []) - + - (['dendrite'] if matrix_dendrite_enabled else []) - ) - }} - -matrix_homeserver_implementation: "{{ matrix_homeserver_enabled_implementations_list[0] if matrix_homeserver_enabled_implementations_list|length == 1 else '' }}" - matrix_identity_server_url: "{{ ('https://' + matrix_server_fqn_matrix) if matrix_ma1sd_enabled else None }}" # If Synapse workers are enabled and matrix-nginx-proxy is disabled, certain APIs may not work over 'http://matrix-synapse:{{ matrix_synapse_container_client_api_port }}'. @@ -1906,6 +1895,8 @@ matrix_client_cinny_self_check_validate_certificates: "{{ false if matrix_ssl_re # ###################################################################### +matrix_synapse_enabled: "{{ matrix_homeserver_implementation == 'synapse' }}" + matrix_synapse_container_image_self_build: "{{ matrix_architecture not in ['arm64', 'amd64'] }}" # When ma1sd is enabled, we can use it to validate email addresses and phone numbers. @@ -2205,6 +2196,8 @@ matrix_postgres_backup_databases: | # ###################################################################### +matrix_dendrite_enabled: "{{ matrix_homeserver_implementation == 'dendrite' }}" + # Normally, matrix-nginx-proxy is enabled and nginx can reach Dendrite over the container network. # If matrix-nginx-proxy is not enabled, or you otherwise have a need for it, # you can expose Dendrite's ports to the host. diff --git a/roles/matrix-base/defaults/main.yml b/roles/matrix-base/defaults/main.yml index 2356c19dd..c71061f8b 100644 --- a/roles/matrix-base/defaults/main.yml +++ b/roles/matrix-base/defaults/main.yml @@ -8,11 +8,13 @@ matrix_domain: ~ # This will contain the homeserver implementation that is in use. -# Example values: 'synapse', 'dendrite', etc. -# You normally don't need to set this variable manually. -# Its value is automatically set depending on the homeserver implementation that you have enabled via other variables -# (e.g. `matrix_synapse_enabled`, `matrix_dendrite_enabled`, etc.) -matrix_homeserver_implementation: '' +# Valid values: synapse, dendrite +# +# By default, we use Synapse, because it's the only full-featured Matrix server at the moment. +# +# This value automatically influences other variables (`matrix_synapse_enabled`, `matrix_dendrite_enabled`, etc.). +# The homeserver implementation of an existing server cannot be changed without data loss. +matrix_homeserver_implementation: synapse # This is where your data lives and what we set up. # This and the Element FQN (see below) are expected to be on the same server. diff --git a/roles/matrix-base/tasks/sanity_check.yml b/roles/matrix-base/tasks/sanity_check.yml index 1e525b80e..b9c8348fd 100644 --- a/roles/matrix-base/tasks/sanity_check.yml +++ b/roles/matrix-base/tasks/sanity_check.yml @@ -1,15 +1,9 @@ --- -- name: Fail if 0 or more than 1 homeserver implementations enabled +- name: Fail if invalid homeserver implementation fail: - msg: >- - You have 0 or more than 1 homeserver implementations enabled - ({{ matrix_homeserver_enabled_implementations_list|join(', ') }}). - - If you have more than 1 implementation enabled, you can disable the unnecessary implementations by adding `matrix_IMPLEMENTATION_enabled: false` to your vars.yml file. - - If you have 0 implementations enabled, you can enable one by adding `matrix_IMPLEMENTATION_enabled: false` to your vars.yml file (e.g. `matrix_dendrite_enabled: true`). - when: "matrix_homeserver_enabled_implementations_list|length != 1" + msg: "You need to set a valid homeserver implementation in `matrix_homeserver_implementation`" + when: "matrix_homeserver_implementation not in ['synapse', 'dendrite']" # We generally support Ansible 2.7.1 and above. - name: Fail if running on Ansible < 2.7.1 diff --git a/roles/matrix-dendrite/defaults/main.yml b/roles/matrix-dendrite/defaults/main.yml index 8cd4c168c..ed15711eb 100644 --- a/roles/matrix-dendrite/defaults/main.yml +++ b/roles/matrix-dendrite/defaults/main.yml @@ -1,7 +1,7 @@ # Dendrite is a second-generation Matrix homeserver currently in Beta # See: https://github.com/matrix-org/dendrite -matrix_dendrite_enabled: false +matrix_dendrite_enabled: true matrix_dendrite_docker_image: "{{ matrix_dendrite_docker_image_name_prefix }}matrixdotorg/dendrite-monolith:{{ matrix_dendrite_docker_image_tag }}" matrix_dendrite_docker_image_name_prefix: "docker.io/"