Enable automatic (SQLite -> Postgres) migration for matrix-appservice-discord
This commit is contained in:
parent
13f84e2ad5
commit
cba973d6b5
|
@ -1,23 +1,29 @@
|
||||||
---
|
---
|
||||||
|
|
||||||
- block:
|
- set_fact:
|
||||||
- name: Check if an SQLite database already exists
|
matrix_appservice_discord_requires_restart: false
|
||||||
stat:
|
|
||||||
path: "{{ matrix_appservice_discord_sqlite_database_path_local }}"
|
|
||||||
register: matrix_appservice_discord_sqlite_database_path_local_stat_result
|
|
||||||
|
|
||||||
- name: Fail if an SQLite database already exists when using Postgres
|
- block:
|
||||||
fail:
|
- name: Check if an SQLite database already exists
|
||||||
msg: >-
|
stat:
|
||||||
matrix_appservice_discord_database_engine has been set to `postgres` (which is our new default now).
|
path: "{{ matrix_appservice_discord_sqlite_database_path_local }}"
|
||||||
However, we've discovered an existing SQLite database in {{ matrix_appservice_discord_sqlite_database_path_local }}.
|
register: matrix_appservice_discord_sqlite_database_path_local_stat_result
|
||||||
It appears that you've been using this bridge with the SQLite engine until now.
|
|
||||||
To continue using SQLite, opt into it explicitly: add `matrix_appservice_discord_database_engine: sqlite` to your vars.yml file and re-run this same command.
|
- block:
|
||||||
Alternatively, to migrate your existing SQLite database to Postgres:
|
- set_fact:
|
||||||
1. Stop all services (`ansible-playbook -i inventory/hosts setup.yml --tags=stop`)
|
matrix_postgres_db_migration_request:
|
||||||
2. Import the SQLite database into Postgres (`ansible-playbook -v -i inventory/hosts setup.yml --tags=import-generic-sqlite-db --extra-vars='sqlite_database_path={{ matrix_appservice_discord_sqlite_database_path_local }} postgres_connection_string_variable_name=matrix_appservice_discord_database_connString'`)
|
src: "{{ matrix_appservice_discord_sqlite_database_path_local }}"
|
||||||
3. Re-run the playbook (`ansible-playbook -i inventory/hosts setup.yml --tags=setup-all,start`)
|
dst: "{{ matrix_appservice_discord_database_connString }}"
|
||||||
when: "matrix_appservice_discord_sqlite_database_path_local_stat_result.stat.exists"
|
caller: "{{ role_path|basename }}"
|
||||||
|
engine_variable_name: 'matrix_appservice_discord_database_engine'
|
||||||
|
engine_old: 'sqlite'
|
||||||
|
systemd_services_to_stop: ['matrix-appservice-discord.service']
|
||||||
|
|
||||||
|
- import_tasks: "roles/matrix-postgres/tasks/util/migrate_db_to_postgres.yml"
|
||||||
|
|
||||||
|
- set_fact:
|
||||||
|
matrix_appservice_discord_requires_restart: true
|
||||||
|
when: "matrix_appservice_discord_sqlite_database_path_local_stat_result.stat.exists|bool"
|
||||||
when: "matrix_appservice_discord_database_engine == 'postgres'"
|
when: "matrix_appservice_discord_database_engine == 'postgres'"
|
||||||
|
|
||||||
- name: Ensure Appservice Discord image is pulled
|
- name: Ensure Appservice Discord image is pulled
|
||||||
|
@ -100,3 +106,9 @@
|
||||||
service:
|
service:
|
||||||
daemon_reload: yes
|
daemon_reload: yes
|
||||||
when: "matrix_appservice_discord_systemd_service_result.changed"
|
when: "matrix_appservice_discord_systemd_service_result.changed"
|
||||||
|
|
||||||
|
- name: Ensure matrix-appservice-discord.service restarted, if necessary
|
||||||
|
service:
|
||||||
|
name: "matrix-appservice-discord.service"
|
||||||
|
state: restarted
|
||||||
|
when: "matrix_appservice_discord_requires_restart|bool"
|
||||||
|
|
Loading…
Reference in a new issue