Matrix Docker Ansible eploy
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 

75 wiersze
2.8 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. {% if matrix_appservice_slack_database_container_network %}
  36. --network={{ matrix_appservice_irc_database_container_network }}
  37. {% endif %}
  38. --mount type=bind,src={{ matrix_appservice_slack_data_path }},dst=/data
  39. --entrypoint=/bin/sh
  40. {{ matrix_appservice_slack_docker_image }}
  41. -c
  42. '/usr/local/bin/node /usr/src/app/lib/scripts/migrateToPostgres.js --dbdir /data --connectionString {{ matrix_appservice_slack_database_connection_string }}'
  43. register: matrix_appservice_slack_import_nedb_to_postgres_result
  44. changed_when: matrix_appservice_slack_import_nedb_to_postgres_result.rc == 0
  45. - name: Archive NeDB database files
  46. ansible.builtin.command:
  47. cmd: "mv {{ matrix_appservice_slack_data_path }}/{{ item }} {{ matrix_appservice_slack_data_path }}/{{ item }}.backup"
  48. register: matrix_appservice_slack_import_nedb_to_postgres_move_result
  49. changed_when: matrix_appservice_slack_import_nedb_to_postgres_move_result.rc == 0
  50. with_items:
  51. - teams.db
  52. - room-store.db
  53. - user-store.db
  54. - event-store.db
  55. - name: Inject result
  56. ansible.builtin.set_fact:
  57. devture_playbook_runtime_messages_list: |
  58. {{
  59. devture_playbook_runtime_messages_list | default([])
  60. +
  61. [
  62. "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."
  63. ]
  64. }}