Matrix Docker Ansible eploy
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

45 lines
2.0 KiB

  1. # SPDX-FileCopyrightText: 2023 Slavi Pantaleev
  2. #
  3. # SPDX-License-Identifier: AGPL-3.0-or-later
  4. ---
  5. - name: Fail if playbook called incorrectly
  6. ansible.builtin.fail:
  7. msg: "The `server_path_homeserver_db` variable needs to be provided to this playbook, via --extra-vars"
  8. when: "server_path_homeserver_db is not defined or server_path_homeserver_db.startswith('<')"
  9. - name: Check if the provided SQLite homeserver.db file exists
  10. ansible.builtin.stat:
  11. path: "{{ server_path_homeserver_db }}"
  12. register: result_server_path_homeserver_db_stat
  13. - name: Fail if provided SQLite homeserver.db file doesn't exist
  14. ansible.builtin.fail:
  15. msg: "File cannot be found on the server at {{ server_path_homeserver_db }}"
  16. when: "not result_server_path_homeserver_db_stat.stat.exists"
  17. # We don't use the `docker_container` module, because using it with `cap_drop` requires
  18. # a very recent version, which is not available for a lot of people yet.
  19. #
  20. # Also, some old `docker_container` versions were buggy and would leave containers behind
  21. # on failure, which we had to work around to allow retries (by re-running the playbook).
  22. - name: Import SQLite database into Postgres
  23. ansible.builtin.command:
  24. cmd: |
  25. docker run
  26. --rm
  27. --name=matrix-synapse-migrate
  28. --log-driver=none
  29. --user={{ matrix_user_uid }}:{{ matrix_user_gid }}
  30. --cap-drop=ALL
  31. --network={{ matrix_synapse_container_network }}
  32. --entrypoint=python
  33. --mount type=bind,src={{ matrix_synapse_config_dir_path }},dst=/data
  34. --mount type=bind,src={{ matrix_synapse_config_dir_path }},dst=/matrix-media-store-parent/media-store
  35. --mount type=bind,src={{ server_path_homeserver_db }},dst=/{{ server_path_homeserver_db | basename }}
  36. {{ matrix_synapse_container_image_final }}
  37. /usr/local/bin/synapse_port_db --sqlite-database /{{ server_path_homeserver_db | basename }} --postgres-config /data/homeserver.yaml
  38. register: matrix_postgres_import_synapse_sqlite_db_result
  39. changed_when: matrix_postgres_import_synapse_sqlite_db_result.rc == 0