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

70 строки
2.7 KiB

  1. ---
  2. # We used to store Postgres data directly under `/matrix/postgres` (what is now considered `matrix_postgres_base_path`).
  3. #
  4. # From now on, we expect to store Postgres data one directory below now (`/matrix/postgres/data` - `matrix_postgres_data_path`).
  5. # We wish to use the base directory for other purposes (storing environment variable files, etc.).
  6. # Mixing those with the Postgres data is no good and it leads to Postgres's `initdb` complaining to initialize
  7. # a database in a non-empty directory.
  8. #
  9. # For this reason, we store the Postgres data in `/matrix/postgres/data` and need to relocate any installations
  10. # which still store it in the parent directory (`/matrix/postgres`).
  11. - name: Check if old Postgres data directory is used
  12. stat:
  13. path: "{{ matrix_postgres_base_path }}/PG_VERSION"
  14. register: result_pg_old_data_dir_stat
  15. - name: Warn if old Postgres data directory detected
  16. debug:
  17. msg: >
  18. Found that you have Postgres data in `{{ matrix_postgres_base_path }}`.
  19. From now on, Postgres data is supposed to be stored in `{{ matrix_postgres_data_path }}` instead.
  20. We'll stop Postgres and relocate the files there for you.
  21. when: "result_pg_old_data_dir_stat.stat.exists"
  22. - name: Find files and directories in old Postgres data path
  23. find:
  24. paths: "{{ matrix_postgres_base_path }}"
  25. file_type: any
  26. excludes: ["data"]
  27. register: "result_pg_old_data_dir_find"
  28. when: "result_pg_old_data_dir_stat.stat.exists"
  29. - name: Ensure new Postgres data path exists
  30. file:
  31. path: "{{ matrix_postgres_data_path }}"
  32. state: directory
  33. mode: 0700
  34. owner: "{{ matrix_user_username }}"
  35. group: "{{ matrix_user_username }}"
  36. when: "result_pg_old_data_dir_stat.stat.exists"
  37. - name: Ensure matrix-postgres is stopped
  38. service:
  39. name: matrix-postgres
  40. state: stopped
  41. daemon_reload: yes
  42. when: "result_pg_old_data_dir_stat.stat.exists"
  43. - block:
  44. - name: Relocate Postgres data files from old directory to new
  45. command: "mv {{ item.path }} {{ matrix_postgres_data_path }}/{{ item.path|basename }}"
  46. with_items: "{{ result_pg_old_data_dir_find.files }}"
  47. when: "result_pg_old_data_dir_stat.stat.exists"
  48. # Intentionally not starting matrix-postgres here.
  49. # It likely needs to be updated to point to the new directory.
  50. # In fact, let's even get rid of the outdated service, to ensure no one will start it
  51. # and have it initialize a new database.
  52. - name: Ensure outdated matrix-postgres.service doesn't exist
  53. file:
  54. path: "/etc/systemd/system/matrix-postgres.service"
  55. state: absent
  56. when: "result_pg_old_data_dir_stat.stat.exists"
  57. - name: Ensure systemd reloaded after getting rid of outdated matrix-postgres.service
  58. service:
  59. daemon_reload: yes
  60. when: "result_pg_old_data_dir_stat.stat.exists"