Matrix Docker Ansible eploy
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 

71 řádky
2.4 KiB

  1. - name: Fail if Postgres not enabled
  2. fail:
  3. msg: "Postgres via the matrix-postgres role is not enabled (`matrix_postgres_enabled`). Cannot migrate."
  4. when: "not matrix_postgres_enabled|bool"
  5. # Defaults
  6. - name: Set postgres_start_wait_time, if not provided
  7. set_fact:
  8. postgres_start_wait_time: 15
  9. when: "postgres_start_wait_time|default('') == ''"
  10. # Actual import work
  11. - name: Ensure matrix-postgres is started
  12. service:
  13. name: matrix-postgres
  14. state: started
  15. daemon_reload: yes
  16. register: matrix_postgres_service_start_result
  17. - name: Wait a bit, so that Postgres can start
  18. wait_for:
  19. timeout: "{{ postgres_start_wait_time }}"
  20. delegate_to: 127.0.0.1
  21. become: false
  22. when: "matrix_postgres_service_start_result.changed|bool"
  23. - name: Check existence of matrix-appservice-irc service
  24. stat:
  25. path: "{{ matrix_systemd_path }}/matrix-appservice-irc.service"
  26. register: matrix_appservice_irc_service_stat
  27. - name: Ensure matrix-appservice-irc is stopped
  28. service:
  29. name: matrix-appservice-irc
  30. state: stopped
  31. when: "matrix_appservice_irc_service_stat.stat.exists"
  32. - name: Import appservice-irc NeDB database into Postgres
  33. command:
  34. cmd: >-
  35. {{ matrix_host_command_docker }} run
  36. --rm
  37. --user={{ matrix_user_uid }}:{{ matrix_user_gid }}
  38. --cap-drop=ALL
  39. --network={{ matrix_docker_network }}
  40. --mount type=bind,src={{ matrix_appservice_irc_data_path }},dst=/data
  41. --entrypoint=/bin/sh
  42. {{ matrix_appservice_irc_docker_image }}
  43. -c
  44. '/usr/local/bin/node /app/lib/scripts/migrate-db-to-pgres.js --dbdir /data --privateKey /data/passkey.pem --connectionString {{ matrix_appservice_irc_database_connection_string }}'
  45. - name: Archive NeDB database files
  46. command:
  47. cmd: "mv {{ matrix_appservice_irc_data_path }}/{{ item }} {{ matrix_appservice_irc_data_path }}/{{ item }}.backup"
  48. with_items:
  49. - rooms.db
  50. - users.db
  51. - name: Inject result
  52. set_fact:
  53. matrix_playbook_runtime_results: |
  54. {{
  55. matrix_playbook_runtime_results|default([])
  56. +
  57. [
  58. "NOTE: Your appservice-irc database files have been imported into Postgres. The original database files have been moved from `{{ matrix_appservice_irc_data_path }}/*.db` to `{{ matrix_appservice_irc_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."
  59. ]
  60. }}