Do not introduce sub-variables exposing implementation details
This commit is contained in:
@ -47,16 +47,23 @@ matrix_appservice_discord_bridge_enableSelfServiceBridging: false
|
||||
#
|
||||
# To use Postgres:
|
||||
# - change the engine (`matrix_appservice_discord_database_engine: 'postgres'`)
|
||||
# - adjust your database credentials
|
||||
# - adjust your database credentials via the `matrix_appservice_discord_postgres_*` variables
|
||||
matrix_appservice_discord_database_engine: 'sqlite'
|
||||
matrix_appservice_discord_database_filename: "/data/{{ matrix_appservice_discord_database_filename_name }}"
|
||||
matrix_appservice_discord_database_filename_name: "discord.db"
|
||||
matrix_appservice_discord_database_connString: 'postgresql://{{ matrix_appservice_discord_database_connString_username }}:{{ matrix_appservice_discord_database_connString_password }}@{{ matrix_appservice_discord_database_connString_hostname }}:{{ matrix_appservice_discord_database_connString_port }}/{{ matrix_appservice_discord_database_connString_db_name }}'
|
||||
matrix_appservice_discord_database_connString_username: 'matrix_appservice_discord'
|
||||
matrix_appservice_discord_database_connString_password: 'some-password'
|
||||
matrix_appservice_discord_database_connString_hostname: 'matrix-postgres'
|
||||
matrix_appservice_discord_database_connString_port: 5432
|
||||
matrix_appservice_discord_database_connString_db_name: 'matrix_appservice_discord'
|
||||
|
||||
matrix_appservice_discord_sqlite_database_path_local: "{{ matrix_appservice_discord_data_path }}/discord.db"
|
||||
matrix_appservice_discord_sqlite_database_path_in_container: "/data/discord.db"
|
||||
|
||||
matrix_appservice_discord_postgres_username: 'matrix_appservice_discord'
|
||||
matrix_appservice_discord_postgres_password: 'some-password'
|
||||
matrix_appservice_discord_postgres_hostname: 'matrix-postgres'
|
||||
matrix_appservice_discord_postgres_port: 5432
|
||||
matrix_appservice_discord_postgres_db_name: 'matrix_appservice_discord'
|
||||
|
||||
# These 2 variables are what actually ends up in the bridge configuration.
|
||||
# It's best if you don't change them directly, but rather redefine the sub-variables that constitute them.
|
||||
matrix_appservice_discord_database_filename: "{{ matrix_appservice_discord_sqlite_database_path_in_container }}"
|
||||
matrix_appservice_discord_database_connString: 'postgresql://{{ matrix_appservice_discord_postgres_username }}:{{ matrix_appservice_discord_postgres_password }}@{{ matrix_appservice_discord_postgres_hostname }}:{{ matrix_appservice_discord_postgres_port }}/{{ matrix_appservice_discord_postgres_db_name }}'
|
||||
|
||||
|
||||
# Tells whether the bot should make use of "Privileged Gateway Intents".
|
||||
#
|
||||
|
@ -1,26 +1,23 @@
|
||||
---
|
||||
|
||||
- block:
|
||||
- set_fact:
|
||||
matrix_appservice_discord_sqlite_db_path: "{{ matrix_appservice_discord_data_path }}/{{ matrix_appservice_discord_database_filename_name }}"
|
||||
|
||||
- name: Check if an SQLite database already exists
|
||||
stat:
|
||||
path: "{{ matrix_appservice_discord_sqlite_db_path }}"
|
||||
register: matrix_appservice_discord_sqlite_db_path_stat_result
|
||||
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
|
||||
fail:
|
||||
msg: >-
|
||||
matrix_appservice_discord_database_engine has been set to `postgres` (which is our new default now).
|
||||
However, we've discovered an existing SQLite database in {{ matrix_appservice_discord_data_path }}/{{ matrix_appservice_discord_database_filename_name }}.
|
||||
However, we've discovered an existing SQLite database in {{ matrix_appservice_discord_sqlite_database_path_local }}.
|
||||
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.
|
||||
Alternatively, to migrate your existing SQLite database to Postgres:
|
||||
1. Stop all services (`ansible-playbook -i inventory/hosts setup.yml --tags=stop`)
|
||||
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_db_path }} postgres_db_connection_string={{ matrix_appservice_discord_database_connString }}'`)
|
||||
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_db_connection_string={{ matrix_appservice_discord_database_connString }}'`)
|
||||
3. Re-run the playbook (`ansible-playbook -i inventory/hosts setup.yml --tags=setup-all,start`)
|
||||
when: "matrix_appservice_discord_sqlite_db_path_stat_result.stat.exists"
|
||||
when: "matrix_appservice_discord_sqlite_database_path_local_stat_result.stat.exists"
|
||||
when: "matrix_appservice_discord_database_engine == 'postgres'"
|
||||
|
||||
- name: Ensure Appservice Discord image is pulled
|
||||
|
Reference in New Issue
Block a user