Matrix Docker Ansible eploy
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 

69 行
2.2 KiB

  1. ---
  2. - name: Fail if Postgres not enabled
  3. fail:
  4. msg: "Postgres via the matrix-postgres role is not enabled (`matrix_postgres_enabled`). Cannot migrate."
  5. when: "not matrix_postgres_enabled|bool"
  6. # Defaults
  7. - name: Set postgres_start_wait_time, if not provided
  8. set_fact:
  9. postgres_start_wait_time: 15
  10. when: "postgres_start_wait_time|default('') == ''"
  11. # Actual import work
  12. - name: Ensure matrix-postgres is started
  13. service:
  14. name: matrix-postgres
  15. state: started
  16. daemon_reload: true
  17. register: matrix_postgres_service_start_result
  18. - name: Wait a bit, so that Postgres can start
  19. wait_for:
  20. timeout: "{{ postgres_start_wait_time }}"
  21. delegate_to: 127.0.0.1
  22. become: false
  23. when: "matrix_postgres_service_start_result.changed|bool"
  24. - name: Ensure matrix-appservice-slack is stopped
  25. service:
  26. name: matrix-appservice-slack
  27. state: stopped
  28. - name: Import appservice-slack NeDB database into Postgres
  29. command:
  30. cmd: >-
  31. {{ matrix_host_command_docker }} run
  32. --rm
  33. --user={{ matrix_user_uid }}:{{ matrix_user_gid }}
  34. --cap-drop=ALL
  35. --network={{ matrix_docker_network }}
  36. --mount type=bind,src={{ matrix_appservice_slack_data_path }},dst=/data
  37. --entrypoint=/bin/sh
  38. {{ matrix_appservice_slack_docker_image }}
  39. -c
  40. '/usr/local/bin/node /usr/src/app/lib/scripts/migrateToPostgres.js --dbdir /data --connectionString {{ matrix_appservice_slack_database_connection_string }}'
  41. - name: Archive NeDB database files
  42. command:
  43. cmd: "mv {{ matrix_appservice_slack_data_path }}/{{ item }} {{ matrix_appservice_slack_data_path }}/{{ item }}.backup"
  44. with_items:
  45. - teams.db
  46. - room-store.db
  47. - user-store.db
  48. - event-store.db
  49. - name: Inject result
  50. set_fact:
  51. matrix_playbook_runtime_results: |
  52. {{
  53. matrix_playbook_runtime_results|default([])
  54. +
  55. [
  56. "NOTE: Your appservice-slack database files have been imported into Postgres. The original database files have been moved from `{{ matrix_appservice_slack_data_path }}/*.db` to `{{ matrix_appservice_slack_data_path }}/*.db.backup`. When you've confirmed that the import went well and everything works, you should be able to safely delete these files."
  57. ]
  58. }}