-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
postgres: create databases for all services #740
Merged
spantaleev
merged 83 commits into
spantaleev:master
from
jdreichmann:postgres-per-default
Dec 23, 2020
Merged
Changes from 36 commits
Commits
Show all changes
83 commits
Select commit
Hold shift + click to select a range
d9f4914
WIP: postgres: create databases for all services
jdreichmann 77a5c7c
Merge branch 'master' into postgres-per-default
spantaleev dac0d3a
Add default matrix_postgres_additional_databases
spantaleev 527d5f5
Relocate Postgres additional database creation logic
spantaleev 0641106
Allow username of additional Postgres databases to be different
spantaleev d251764
Fix syntax issues in matrix_postgres_additional_databases
spantaleev f47e8a9
Make use of matrix_host_command_docker instead of hardcoding
spantaleev e2952f1
Determine matrix-postgres IP address without relying on jq
spantaleev c765ceb
Prevent weird loop error
spantaleev bbc09d0
Do not execute additional databases creation code if not necessary
spantaleev da4cb2f
Do not use the postgresql_user/postgresql_db modules
spantaleev 3a037a5
Ensure additional databases contain all the keys that we expect
spantaleev 46a4034
Use "password" for additional Postgres databases, not "pass"
spantaleev a374d30
Make appservice-discord support both SQLite and Postgres
spantaleev 183d2a1
Ensure matrix-postgres.service is started before creating additional …
spantaleev dd99499
Simplify password for additional Postgres databases
spantaleev b87b754
Fail if appservice-discord wants Postgres, but has leftover SQLite data
spantaleev c66c084
Merge branch 'master' into postgres-per-default
spantaleev cb969c6
Add --tags=import-generic-sqlite-db (pgloader import)
spantaleev 4617984
Add (SQLite -> Postgres) migration instructions
spantaleev b217a2e
postgres: set default in playbook to postgres but fallback to sqlite
jdreichmann f1e85f7
Don't mention Postgres roles, just say users
spantaleev d91aa5a
Do not introduce sub-variables exposing implementation details
spantaleev c0edacb
Fix matrix_postgres_additional_databases syntax problems
spantaleev 2a99e84
Rename Postgres-related variables (`matrix*database_*` -> `matrix*pos…
spantaleev 5dba0c0
Make --tags=import-generic-sqlite-db commands not pass a sensitive co…
spantaleev 2d99ade
Add (Postgres + SQLite) support to matrix-mautrix-facebook bridge
spantaleev a3406a1
Move some things around
spantaleev 9bf8ce8
Add (Postgres + SQLite) support to matrix-mautrix-telegram bridge
spantaleev 05dd091
Rename `_database_hostname` to `_postgres_hostname`
spantaleev 6a2dd80
Fix typo (matrix_telegram_facebook_postgres_hostname -> matrix_mautri…
spantaleev 2848322
Remove some remaining `_database_password` usage in favor of `_postgr…
spantaleev 6c77eae
Add (Postgres + SQLite) support to matrix-mautrix-whatsapp bridge
spantaleev 43d6ff2
Fix sqlite usage for mautrix-facebook/mautrix-telegram
spantaleev ce21ea3
Add (Postgres + SQLite) support to matrix-mautrix-hangouts bridge
spantaleev 087dbe4
Rename `matrix_*_postgres_*` back to `matrix_*_database_*`
spantaleev 5d70bc1
add postgres support for mx-puppet-* with fallback to sqlite in role …
jdreichmann b9a04a7
Rename some remaining `matrix_*_postgres_*` vars back to `matrix_*_da…
spantaleev aa828ff
Separate matrix-reminder-bot install/uninstall tasks
spantaleev dde1c9f
Fix indentation causing YAML syntax error
spantaleev e3a0c9a
Add (Postgres + SQLite) support to matrix-reminder-bot
spantaleev 54da61f
add postgres support mx-appservice-[slack|irc] with fallback to nedb …
jdreichmann bc376c2
Add database migration utility to matrix-postgres role
spantaleev dc7850e
Fix wording and variable names a bit
spantaleev ac37091
Enable automatic (SQLite -> Postgres) migration for matrix-reminder-bot
spantaleev c1431b2
Make use of matrix_postgres_db_migration_request.caller
spantaleev bbc0872
Enable automatic (SQLite -> Postgres) migration for matrix-mautrix-fa…
spantaleev 3ba8520
Enable automatic (SQLite -> Postgres) migration for matrix-mautrix-ha…
spantaleev 86a8091
Enable automatic (SQLite -> Postgres) migration for matrix-mautrix-te…
spantaleev 13f84e2
Enable automatic (SQLite -> Postgres) migration for matrix-mautrix-wh…
spantaleev cba973d
Enable automatic (SQLite -> Postgres) migration for matrix-appservice…
spantaleev 7248eb3
Fix syntax error in roles/matrix-bridge-appservice-irc/defaults/main.yml
spantaleev 0ca48f3
Separate matrix-ma1sd install/uninstall tasks
spantaleev af3ea67
Add (SQLite + Postgres) support and automatic migration to matrix-ma1sd
spantaleev 3ab7dd1
Potentially add matrix-postgres.service as required for bridges, etc.
spantaleev 13d8a9b
hint supported automatic migration nedb->postgres
jdreichmann 516ccb2
Separate matrix-registration install/uninstall tasks
spantaleev 8d74593
Prepare matrix-registation for (SQLite + Postgres) support
spantaleev 374f437
Separate matrix-dimension install/uninstall tasks
spantaleev 0790a7b
Add support for matrix_dimension_systemd_{required,wanted}_services_list
spantaleev 2a502db
Add (SQLite + Postgres) support and automatic migration to matrix-dim…
spantaleev dd797ba
Fix Postgres database importing/upgrading conflicts
spantaleev e2ba46b
Fix Jinja2 syntax error (else if -> elif)
spantaleev 3289298
Merge branch 'master' into postgres-per-default
spantaleev 1bd5c24
Add support for executing additional DB migration statements
spantaleev a197968
Make matrix-registration use Postgres by default
spantaleev 0f4649a
Merge branch 'master' into postgres-per-default
spantaleev 6488e11
Relocate some tasks
spantaleev 9b4bf73
Fix undefined variable reference
spantaleev 149872e
Add support for automatic (Postgres -> SQLite) migration to mx-puppet…
spantaleev e64758c
Add missing restart task
spantaleev 44c9f4d
Add support for automatic (Postgres -> SQLite) migration to mx-puppet…
spantaleev d135cd9
Ensure mx-puppet-discord directories are created before attempting mi…
spantaleev e49eb07
Add support for automatic (Postgres -> SQLite) migration to mx-puppet…
spantaleev 262a25f
Add support for automatic (Postgres -> SQLite) migration to mx-puppet…
spantaleev 69cc214
Add support for automatic (Postgres -> SQLite) migration to mx-puppet…
spantaleev ab6563c
Add support for automatic (Postgres -> SQLite) migration to mx-puppet…
spantaleev 15f4cc9
Rename variables (_database_db_name -> _database_name)
spantaleev 815a80c
Fix alignment issues
spantaleev 715bdf2
Add support for automatic (nedb -> Postgres) migration to mx-appservi…
spantaleev 9b95e19
Auto-restart matrix-appservice-irc after (nedb -> Postgres) migration
spantaleev 8675ded
Add support for automatic (nedb -> Postgres) migration to matrix-apps…
spantaleev ad1425e
Add pgloader self-building support (for ARM)
spantaleev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
roles/matrix-bridge-appservice-discord/tasks/setup_install.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we could do sth here with
import_tasks
for an automigrationThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Auto-migration would be ideal. At first I started on that, but then I figured it might be somewhat dangerous.
For example, importing the Appservice Discord database always gives me at least a few errors ("... cannot have multiple primary keys in
emoji
table", etc). As of yet, I'm still not sure how perfectly that migration went.So it makes me see it as something a bit dangerous and a somewhat big change, that users should do explicitly (similar to how we don't auto-upgrade between Postgres versions -- although that's even more dangerous).
Doing auto-migration also seemed more difficult to do, as it involves:
import_tasks
(should be easy). This likely involves doing the samefile.db
->file.db.backup
renameconfig.yml
after all, as there's nofile.db
database anymore and it's all in Postgres already. If the bridge were to be started at this moment, it would create a new empty database (likely not too catastrophic though).matrix-common-after
)? If someone does just--tags=setup-appservice-discord
, then we won't even make it to where we expect to inmatrix-common-after
. Well, that's rare, but ..It should be possible to have auto-migration though. What we have now is a little annoying to use.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An alternative to both auto-migration and erroring-out like we do now is to: detect that there's leftover SQLite data and automatically switch to using SQLite when generating the configuration.
We could leave the
matrix_postgres_additional_databases
definitions in place and have these empty databases get created and left unused.Whenever we detect that leftover data and auto-switch to SQLite, we could push a warning (notice) message to be displayed at the end of playbook execution. We do such a thing for major Postgres upgrades. We automatically keep people on the old version (instead of trying to auto-upgrade them), and we tell them with a message, letting them run the upgrade whenever they feel comfortable. Code is here:
matrix-docker-ansible-deploy/roles/matrix-postgres/tasks/setup_postgres.yml
Lines 21 to 31 in 6e1dfb6
What do you think? To me, it sounds reasonable and simple to implement.. It's also not dangerous.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That adds an extra layer of "let the user choose", and i think it becomes harder and harder to keep the change small. ideally, we would automigrate everything and have the roles themselves with sqlite as default, supporting delaying, external postgres, etc etc blows up the scope, and users would except that a merged feature was tested with every combination.
TL;DR: could do, but might bite us later, and we should encourage users to migrate to postgres by making the path to migrate easy (encourage users to actually do it and not perpetually delay it)