Matrix Docker Ansible eploy
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 

81 lignes
3.0 KiB

  1. # SPDX-FileCopyrightText: 2020 - 2024 Slavi Pantaleev
  2. # SPDX-FileCopyrightText: 2022 Marko Weltzer
  3. # SPDX-FileCopyrightText: 2024 Suguru Hirahara
  4. #
  5. # SPDX-License-Identifier: AGPL-3.0-or-later
  6. ---
  7. - name: Fail if Postgres not enabled
  8. ansible.builtin.fail:
  9. msg: "Postgres via ansible-role-postgres role is not enabled (`postgres_enabled`). Cannot migrate."
  10. when: "not postgres_enabled | bool"
  11. # Defaults
  12. - name: Set postgres_start_wait_time, if not provided
  13. ansible.builtin.set_fact:
  14. postgres_start_wait_time: 15
  15. when: "postgres_start_wait_time | default('') == ''"
  16. # Actual import work
  17. - name: Ensure Postgres is started
  18. ansible.builtin.service:
  19. name: "{{ postgres_identifier }}"
  20. state: started
  21. daemon_reload: true
  22. register: postgres_service_start_result
  23. - name: Wait a bit, so that Postgres can start
  24. ansible.builtin.wait_for:
  25. timeout: "{{ postgres_start_wait_time }}"
  26. delegate_to: 127.0.0.1
  27. become: false
  28. when: "postgres_service_start_result.changed | bool"
  29. - name: Ensure matrix-appservice-slack is stopped
  30. ansible.builtin.service:
  31. name: matrix-appservice-slack
  32. state: stopped
  33. - name: Import appservice-slack NeDB database into Postgres
  34. ansible.builtin.command:
  35. cmd: >-
  36. {{ devture_systemd_docker_base_host_command_docker }} run
  37. --rm
  38. --user={{ matrix_user_uid }}:{{ matrix_user_gid }}
  39. --cap-drop=ALL
  40. {% if matrix_appservice_slack_database_container_network %}
  41. --network={{ matrix_appservice_irc_database_container_network }}
  42. {% endif %}
  43. --mount type=bind,src={{ matrix_appservice_slack_data_path }},dst=/data
  44. --entrypoint=/bin/sh
  45. {{ matrix_appservice_slack_docker_image }}
  46. -c
  47. '/usr/local/bin/node /usr/src/app/lib/scripts/migrateToPostgres.js --dbdir /data --connectionString {{ matrix_appservice_slack_database_connection_string }}'
  48. register: matrix_appservice_slack_import_nedb_to_postgres_result
  49. changed_when: matrix_appservice_slack_import_nedb_to_postgres_result.rc == 0
  50. - name: Archive NeDB database files
  51. ansible.builtin.command:
  52. cmd: "mv {{ matrix_appservice_slack_data_path }}/{{ item }} {{ matrix_appservice_slack_data_path }}/{{ item }}.backup"
  53. register: matrix_appservice_slack_import_nedb_to_postgres_move_result
  54. changed_when: matrix_appservice_slack_import_nedb_to_postgres_move_result.rc == 0
  55. with_items:
  56. - teams.db
  57. - room-store.db
  58. - user-store.db
  59. - event-store.db
  60. - name: Inject result
  61. ansible.builtin.set_fact:
  62. devture_playbook_runtime_messages_list: |
  63. {{
  64. devture_playbook_runtime_messages_list | default([])
  65. +
  66. [
  67. "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."
  68. ]
  69. }}