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.
 
 

76 líneas
2.5 KiB

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