From 8c25ade9fb6d3badfdfd673acbd39e67cfef0fa9 Mon Sep 17 00:00:00 2001 From: Slavi Pantaleev Date: Tue, 8 Mar 2022 08:10:40 +0200 Subject: [PATCH] Rework matrix_mautrix_twitter_database_* variables a bit Related to https://github.com/spantaleev/matrix-docker-ansible-deploy/issues/1682 Previously, when matrix-postgres was disabled, we were setting `matrix_mautrix_twitter_database_engine` to an invalid empty value. Now, we always hardcode `matrix_mautrix_twitter_database_engine: postgres`, but set/unset the database hostname and password values instead. --- group_vars/matrix_servers | 6 ++---- roles/matrix-bridge-mautrix-twitter/defaults/main.yml | 4 ++-- .../tasks/validate_config.yml | 10 ++-------- 3 files changed, 6 insertions(+), 14 deletions(-) diff --git a/group_vars/matrix_servers b/group_vars/matrix_servers index 97b7cf701..4301ae7eb 100755 --- a/group_vars/matrix_servers +++ b/group_vars/matrix_servers @@ -558,10 +558,8 @@ matrix_mautrix_twitter_homeserver_token: "{{ matrix_homeserver_generic_secret_ke matrix_mautrix_twitter_login_shared_secret: "{{ matrix_synapse_ext_password_provider_shared_secret_auth_shared_secret if matrix_synapse_ext_password_provider_shared_secret_auth_enabled else '' }}" -# We'd like to force-set people with external Postgres to SQLite, so the bridge role can complain -# and point them to a migration path. -matrix_mautrix_twitter_database_engine: "{{ 'postgres' if matrix_postgres_enabled else '' }}" -matrix_mautrix_twitter_database_password: "{{ matrix_homeserver_generic_secret_key | password_hash('sha512', 'mau.twt.db') | to_uuid }}" +matrix_mautrix_twitter_database_hostname: "{{ 'matrix-postgres' if matrix_postgres_enabled else '' }}" +matrix_mautrix_twitter_database_password: "{{ matrix_homeserver_generic_secret_key | password_hash('sha512', 'mau.twt.db') | to_uuid if matrix_postgres_enabled else '' }}" ###################################################################### # diff --git a/roles/matrix-bridge-mautrix-twitter/defaults/main.yml b/roles/matrix-bridge-mautrix-twitter/defaults/main.yml index f8fd29c80..4ab1303de 100644 --- a/roles/matrix-bridge-mautrix-twitter/defaults/main.yml +++ b/roles/matrix-bridge-mautrix-twitter/defaults/main.yml @@ -42,8 +42,8 @@ matrix_mautrix_twitter_homeserver_token: '' matrix_mautrix_twitter_database_engine: 'postgres' matrix_mautrix_twitter_database_username: 'matrix_mautrix_twitter' -matrix_mautrix_twitter_database_password: 'some-password' -matrix_mautrix_twitter_database_hostname: 'matrix-postgres' +matrix_mautrix_twitter_database_password: '' +matrix_mautrix_twitter_database_hostname: '' matrix_mautrix_twitter_database_port: 5432 matrix_mautrix_twitter_database_name: 'matrix_mautrix_twitter' diff --git a/roles/matrix-bridge-mautrix-twitter/tasks/validate_config.yml b/roles/matrix-bridge-mautrix-twitter/tasks/validate_config.yml index 114fd2cf0..5b6e3d020 100644 --- a/roles/matrix-bridge-mautrix-twitter/tasks/validate_config.yml +++ b/roles/matrix-bridge-mautrix-twitter/tasks/validate_config.yml @@ -8,11 +8,5 @@ with_items: - "matrix_mautrix_twitter_appservice_token" - "matrix_mautrix_twitter_homeserver_token" - -- name: Fail if database is not defined - fail: - msg: >- - You need to define a need to set `matrix_mautrix_twitter_database_engine: postgres` and redefine the other `matrix_mautrix_twitter_database_*` variables - when: "vars[item] == ''" - with_items: - - "matrix_mautrix_twitter_database_engine" + - "matrix_mautrix_twitter_database_hostname" + - "matrix_mautrix_twitter_database_password"