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

72 строки
2.8 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. # We should stop Postgres first, before building a list of files,
  23. # as to ignore any `postmaster.pid` files, etc.
  24. - name: Ensure matrix-postgres is stopped
  25. service:
  26. name: matrix-postgres
  27. state: stopped
  28. daemon_reload: yes
  29. when: "result_pg_old_data_dir_stat.stat.exists"
  30. - name: Find files and directories in old Postgres data path
  31. find:
  32. paths: "{{ matrix_postgres_base_path }}"
  33. file_type: any
  34. excludes: ["data"]
  35. register: "result_pg_old_data_dir_find"
  36. when: "result_pg_old_data_dir_stat.stat.exists"
  37. - name: Ensure new Postgres data path exists
  38. file:
  39. path: "{{ matrix_postgres_data_path }}"
  40. state: directory
  41. mode: 0700
  42. owner: "{{ matrix_user_username }}"
  43. group: "{{ matrix_user_username }}"
  44. when: "result_pg_old_data_dir_stat.stat.exists"
  45. - block:
  46. - name: Relocate Postgres data files from old directory to new
  47. command: "mv {{ item.path }} {{ matrix_postgres_data_path }}/{{ item.path|basename }}"
  48. with_items: "{{ result_pg_old_data_dir_find.files }}"
  49. when: "result_pg_old_data_dir_stat.stat.exists"
  50. # Intentionally not starting matrix-postgres here.
  51. # It likely needs to be updated to point to the new directory.
  52. # In fact, let's even get rid of the outdated service, to ensure no one will start it
  53. # and have it initialize a new database.
  54. - name: Ensure outdated matrix-postgres.service doesn't exist
  55. file:
  56. path: "/etc/systemd/system/matrix-postgres.service"
  57. state: absent
  58. when: "result_pg_old_data_dir_stat.stat.exists"
  59. - name: Ensure systemd reloaded after getting rid of outdated matrix-postgres.service
  60. service:
  61. daemon_reload: yes
  62. when: "result_pg_old_data_dir_stat.stat.exists"