Matrix Docker Ansible eploy
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
 
 

73 行
2.4 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: Check existence of matrix-appservice-irc service
  25. stat:
  26. path: "{{ matrix_systemd_path }}/matrix-appservice-irc.service"
  27. register: matrix_appservice_irc_service_stat
  28. - name: Ensure matrix-appservice-irc is stopped
  29. service:
  30. name: matrix-appservice-irc
  31. state: stopped
  32. when: "matrix_appservice_irc_service_stat.stat.exists"
  33. - name: Import appservice-irc NeDB database into Postgres
  34. command:
  35. cmd: >-
  36. {{ matrix_host_command_docker }} run
  37. --rm
  38. --user={{ matrix_user_uid }}:{{ matrix_user_gid }}
  39. --cap-drop=ALL
  40. --network={{ matrix_docker_network }}
  41. --mount type=bind,src={{ matrix_appservice_irc_data_path }},dst=/data
  42. --entrypoint=/bin/sh
  43. {{ matrix_appservice_irc_docker_image }}
  44. -c
  45. '/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 }}'
  46. - name: Archive NeDB database files
  47. command:
  48. cmd: "mv {{ matrix_appservice_irc_data_path }}/{{ item }} {{ matrix_appservice_irc_data_path }}/{{ item }}.backup"
  49. with_items:
  50. - rooms.db
  51. - users.db
  52. - name: Inject result
  53. set_fact:
  54. matrix_playbook_runtime_results: |
  55. {{
  56. matrix_playbook_runtime_results|default([])
  57. +
  58. [
  59. "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."
  60. ]
  61. }}