Matrix Docker Ansible eploy
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

73 строки
2.5 KiB

  1. ---
  2. - name: Fail if playbook called incorrectly
  3. fail: msg="The `local_path_homeserver_db` variable needs to be provided to this playbook, via --extra-vars"
  4. when: "local_path_homeserver_db is not defined or local_path_homeserver_db.startswith('<')"
  5. - name: Check if the provided SQLite homeserver.db file exists
  6. stat: path="{{ local_path_homeserver_db }}"
  7. delegate_to: 127.0.0.1
  8. become: false
  9. register: local_path_homeserver_db_stat
  10. - name: Fail if provided SQLite homeserver.db file doesn't exist
  11. fail: msg="File cannot be found on the local machine at {{ local_path_homeserver_db }}"
  12. when: not local_path_homeserver_db_stat.stat.exists
  13. - name: Ensure scratchpad directory exists
  14. file:
  15. path: "{{ matrix_scratchpad_dir }}"
  16. state: directory
  17. mode: 0755
  18. owner: "{{ matrix_user_username }}"
  19. group: "{{ matrix_user_username }}"
  20. - name: Ensure provided SQLite homeserver.db file is copied to scratchpad directory on the server
  21. synchronize:
  22. src: "{{ local_path_homeserver_db }}"
  23. dest: "{{ matrix_scratchpad_dir }}/homeserver.db"
  24. - name: Ensure matrix-postgres is stopped
  25. service: name=matrix-postgres state=stopped 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: name=matrix-postgres state=restarted daemon_reload=yes
  39. - name: Wait a while, so that Postgres can manage to start
  40. pause: seconds=7
  41. - name: Importing SQLite database into Postgres
  42. docker_container:
  43. name: matrix-synapse-migrate
  44. image: "{{ matrix_synapse_docker_image }}"
  45. detach: no
  46. cleanup: yes
  47. entrypoint: /usr/bin/python
  48. command: "/usr/local/bin/synapse_port_db --sqlite-database /scratchpad/homeserver.db --postgres-config /data/homeserver.yaml"
  49. user: "{{ matrix_user_uid }}:{{ matrix_user_gid }}"
  50. volumes:
  51. - "{{ matrix_synapse_config_dir_path }}:/data"
  52. - "{{ matrix_synapse_run_path }}:/matrix-run"
  53. - "{{ matrix_synapse_media_store_path }}:/matrix-media-store"
  54. - "{{ matrix_scratchpad_dir }}:/scratchpad"
  55. links:
  56. - "matrix-postgres:{{ matrix_postgres_connection_hostname }}"
  57. - name: Ensure scratchpad directory is deleted
  58. file:
  59. path: "{{ matrix_scratchpad_dir }}"
  60. state: absent