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

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