Prepare matrix-registation for (SQLite + Postgres) support

Auto-migration and everything seems to work. It's just that
matrix-registration cannot load the Python modules required
for talking to a Postgres database.

Tracked here: https://github.com/ZerataX/matrix-registration/issues/44

Until this gets fixed, we'll continue default to 'sqlite'.
This commit is contained in:
Slavi Pantaleev
2020-12-14 18:58:37 +02:00
parent 516ccb2b2b
commit 8d74593878
5 changed files with 88 additions and 1 deletions

View File

@ -1,5 +1,31 @@
---
- set_fact:
matrix_registration_requires_restart: false
- block:
- name: Check if an SQLite database already exists
stat:
path: "{{ matrix_registration_sqlite_database_path_local }}"
register: matrix_registration_sqlite_database_path_local_stat_result
- block:
- set_fact:
matrix_postgres_db_migration_request:
src: "{{ matrix_registration_sqlite_database_path_local }}"
dst: "{{ matrix_registration_database_connection_string }}"
caller: "{{ role_path|basename }}"
engine_variable_name: 'matrix_registration_database_engine'
engine_old: 'sqlite'
systemd_services_to_stop: ['matrix-registration.service']
- import_tasks: "roles/matrix-postgres/tasks/util/migrate_db_to_postgres.yml"
- set_fact:
matrix_registration_requires_restart: true
when: "matrix_registration_sqlite_database_path_local_stat_result.stat.exists|bool"
when: "matrix_registration_database_engine == 'postgres'"
- name: Ensure matrix-registration paths exist
file:
path: "{{ item.path }}"
@ -61,3 +87,9 @@
service:
daemon_reload: yes
when: "matrix_registration_systemd_service_result.changed|bool"
- name: Ensure matrix-registration.service restarted, if necessary
service:
name: "matrix-registration.service"
state: restarted
when: "matrix_registration_requires_restart|bool"

View File

@ -18,3 +18,10 @@
when: "item.old in vars"
with_items:
- {'old': 'matrix_registration_docker_repo', 'new': 'matrix_registration_container_image_self_build_repo'}
- name: Fail if Postgres usage attempted
fail:
msg: >
matrix-registration doesn't support using Postgres just yet.
Learn more here: https://github.com/ZerataX/matrix-registration/issues/44
when: "matrix_registration_database_engine == 'postgres'"