mirror of
https://github.com/spantaleev/matrix-docker-ansible-deploy.git
synced 2024-12-26 19:08:31 +01:00
51312b8250
As suggested in #63 (Github issue), splitting the playbook's logic into multiple roles will be beneficial for maintainability. This patch realizes this split. Still, some components affect others, so the roles are not really independent of one another. For example: - disabling mxisd (`matrix_mxisd_enabled: false`), causes Synapse and riot-web to reconfigure themselves with other (public) Identity servers. - enabling matrix-corporal (`matrix_corporal_enabled: true`) affects how reverse-proxying (by `matrix-nginx-proxy`) is done, in order to put matrix-corporal's gateway server in front of Synapse We may be able to move away from such dependencies in the future, at the expense of a more complicated manual configuration, but it's probably not worth sacrificing the convenience we have now. As part of this work, the way we do "start components" has been redone now to use a loop, as suggested in #65 (Github issue). This should make restarting faster and more reliable.
61 lines
1.8 KiB
YAML
61 lines
1.8 KiB
YAML
---
|
|
|
|
# Pre-checks
|
|
|
|
- name: Fail if playbook called incorrectly
|
|
fail:
|
|
msg: "The `server_path_postgres_dump` variable needs to be provided to this playbook, via --extra-vars"
|
|
when: "server_path_postgres_dump is not defined or server_path_postgres_dump.startswith('<')"
|
|
|
|
- name: Check if the provided Postgres dump file exists
|
|
stat:
|
|
path: "{{ server_path_postgres_dump }}"
|
|
register: result_server_path_postgres_dump_stat
|
|
|
|
- name: Fail if provided Postgres dump file doesn't exists
|
|
fail:
|
|
msg: "File cannot be found on the server at {{ server_path_postgres_dump }}"
|
|
when: not result_server_path_postgres_dump_stat.stat.exists
|
|
|
|
- import_tasks: tasks/util/detect_existing_postgres_version.yml
|
|
|
|
- name: Abort, if no existing Postgres version detected
|
|
fail:
|
|
msg: "Could not find existing Postgres installation"
|
|
when: "not matrix_postgres_detected_existing"
|
|
|
|
|
|
# Defaults
|
|
|
|
- name: Set postgres_start_wait_time, if not provided
|
|
set_fact:
|
|
postgres_start_wait_time: 15
|
|
when: "postgres_start_wait_time|default('') == ''"
|
|
|
|
|
|
# Actual import work
|
|
|
|
- name: Ensure matrix-postgres is started
|
|
service:
|
|
name: matrix-postgres
|
|
state: started
|
|
daemon_reload: yes
|
|
|
|
- name: Wait a bit, so that Postgres can start
|
|
wait_for:
|
|
timeout: "{{ postgres_start_wait_time }}"
|
|
delegate_to: 127.0.0.1
|
|
become: false
|
|
|
|
- name: Perform Postgres database import
|
|
command: |
|
|
/usr/bin/docker run --rm --name matrix-postgres-import \
|
|
--network={{ matrix_docker_network }} \
|
|
--env-file={{ matrix_postgres_base_path }}/env-postgres-psql \
|
|
-v {{ server_path_postgres_dump }}:{{ server_path_postgres_dump }}:ro \
|
|
--entrypoint=/bin/sh
|
|
{{ matrix_postgres_docker_image_latest }}
|
|
-c 'cat {{ server_path_postgres_dump }} | \
|
|
{{ 'gunzip |' if server_path_postgres_dump.endswith('.gz') else '' }}
|
|
psql -v ON_ERROR_STOP=1 -h matrix-postgres'
|