Matrix Docker Ansible eploy
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

73 строки
2.7 KiB

  1. ---
  2. - name: Fail if Postgres not enabled
  3. ansible.builtin.fail:
  4. msg: "Postgres via the com.devture.ansible.role.postgres role is not enabled (`devture_postgres_enabled`). Cannot migrate."
  5. when: "not devture_postgres_enabled | bool"
  6. # Defaults
  7. - name: Set postgres_start_wait_time, if not provided
  8. ansible.builtin.set_fact:
  9. postgres_start_wait_time: 15
  10. when: "postgres_start_wait_time | default('') == ''"
  11. # Actual import work
  12. - name: Ensure Postgres is started
  13. ansible.builtin.service:
  14. name: "{{ devture_postgres_identifier }}"
  15. state: started
  16. daemon_reload: true
  17. register: postgres_service_start_result
  18. - name: Wait a bit, so that Postgres can start
  19. ansible.builtin.wait_for:
  20. timeout: "{{ postgres_start_wait_time }}"
  21. delegate_to: 127.0.0.1
  22. become: false
  23. when: "postgres_service_start_result.changed | bool"
  24. - name: Ensure matrix-appservice-slack is stopped
  25. ansible.builtin.service:
  26. name: matrix-appservice-slack
  27. state: stopped
  28. - name: Import appservice-slack NeDB database into Postgres
  29. ansible.builtin.command:
  30. cmd: >-
  31. {{ devture_systemd_docker_base_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. register: matrix_appservice_slack_import_nedb_to_postgres_result
  42. changed_when: matrix_appservice_slack_import_nedb_to_postgres_result.rc == 0
  43. - name: Archive NeDB database files
  44. ansible.builtin.command:
  45. cmd: "mv {{ matrix_appservice_slack_data_path }}/{{ item }} {{ matrix_appservice_slack_data_path }}/{{ item }}.backup"
  46. register: matrix_appservice_slack_import_nedb_to_postgres_move_result
  47. changed_when: matrix_appservice_slack_import_nedb_to_postgres_move_result.rc == 0
  48. with_items:
  49. - teams.db
  50. - room-store.db
  51. - user-store.db
  52. - event-store.db
  53. - name: Inject result
  54. ansible.builtin.set_fact:
  55. devture_playbook_runtime_messages_list: |
  56. {{
  57. devture_playbook_runtime_messages_list | default([])
  58. +
  59. [
  60. "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."
  61. ]
  62. }}