Matrix Docker Ansible eploy
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 

85 líneas
2.5 KiB

  1. ---
  2. # Pre-checks
  3. - name: Fail if playbook called incorrectly
  4. fail:
  5. msg: "The `server_path_homeserver_db` variable needs to be provided to this playbook, via --extra-vars"
  6. when: "server_path_homeserver_db is not defined or server_path_homeserver_db.startswith('<')"
  7. - name: Check if the provided SQLite homeserver.db file exists
  8. stat:
  9. path: "{{ server_path_homeserver_db }}"
  10. register: result_server_path_homeserver_db_stat
  11. - name: Fail if provided SQLite homeserver.db file doesn't exist
  12. fail:
  13. msg: "File cannot be found on the server at {{ server_path_homeserver_db }}"
  14. when: not result_server_path_homeserver_db_stat.stat.exists
  15. # Defaults
  16. - name: Set postgres_start_wait_time, if not provided
  17. set_fact:
  18. postgres_start_wait_time: 15
  19. when: "postgres_start_wait_time|default('') == ''"
  20. # Actual import work
  21. - name: Ensure matrix-postgres is stopped
  22. service:
  23. name: matrix-postgres
  24. state: stopped
  25. daemon_reload: yes
  26. - name: Ensure postgres data is wiped out
  27. file:
  28. path: "{{ matrix_postgres_data_path }}"
  29. state: absent
  30. - name: Ensure postgres data path exists
  31. file:
  32. path: "{{ matrix_postgres_data_path }}"
  33. state: directory
  34. mode: 0700
  35. owner: "{{ matrix_user_username }}"
  36. group: "{{ matrix_user_username }}"
  37. - name: Ensure matrix-postgres is started
  38. service:
  39. name: matrix-postgres
  40. state: restarted
  41. daemon_reload: yes
  42. - name: Wait a bit, so that Postgres can start
  43. wait_for:
  44. timeout: "{{ postgres_start_wait_time }}"
  45. delegate_to: 127.0.0.1
  46. become: false
  47. # If the actual migration command (below) fails, it will leave a container behind.
  48. # Starting it again later will relaunch that one, which may or may not work.
  49. # To ensure we're starting from a clean state, ensure any such leftovers are removed.
  50. - name: Cleanup any old leftover migration container
  51. docker_container:
  52. name: matrix-synapse-migrate
  53. state: absent
  54. - name: Importing SQLite database into Postgres
  55. docker_container:
  56. name: matrix-synapse-migrate
  57. image: "{{ matrix_synapse_docker_image }}"
  58. detach: no
  59. cleanup: yes
  60. entrypoint: /usr/local/bin/python
  61. command: "/usr/local/bin/synapse_port_db --sqlite-database {{ server_path_homeserver_db }} --postgres-config /data/homeserver.yaml"
  62. user: "{{ matrix_user_uid }}:{{ matrix_user_gid }}"
  63. volumes:
  64. - "{{ matrix_synapse_config_dir_path }}:/data"
  65. - "{{ matrix_synapse_run_path }}:/matrix-run"
  66. - "{{ server_path_homeserver_db }}:/{{ server_path_homeserver_db }}:ro"
  67. networks:
  68. - name: "{{ matrix_docker_network }}"