Matrix Docker Ansible eploy
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 

89 řádky
3.3 KiB

  1. # SPDX-FileCopyrightText: 2024 MDAD Team and contributors
  2. #
  3. # SPDX-License-Identifier: AGPL-3.0-or-later
  4. ---
  5. # Pre-checks
  6. - name: Fail if playbook called incorrectly
  7. ansible.builtin.fail:
  8. msg: "The `server_path_media_store` variable needs to be provided to this playbook, via --extra-vars"
  9. when: "server_path_media_store is not defined or server_path_media_store.startswith('<')"
  10. - name: Fail if media store is on Amazon S3
  11. ansible.builtin.fail:
  12. msg: "Your media store is on Amazon S3. Due to technical limitations, restoring is not supported."
  13. when: matrix_s3_media_store_enabled | bool
  14. - name: Check if the provided media store directory exists
  15. ansible.builtin.stat:
  16. path: "{{ server_path_media_store }}"
  17. register: server_path_media_store_stat
  18. - name: Fail if provided media store directory doesn't exist on the server
  19. ansible.builtin.fail:
  20. msg: "{{ server_path_media_store }} cannot be found on the server"
  21. when: "not server_path_media_store_stat.stat.exists or not server_path_media_store_stat.stat.isdir"
  22. - name: Check if media store contains local_content
  23. ansible.builtin.stat:
  24. path: "{{ server_path_media_store }}/local_content"
  25. register: server_path_media_store_local_content_stat
  26. - name: Check if media store contains remote_content
  27. ansible.builtin.stat:
  28. path: "{{ server_path_media_store }}/remote_content"
  29. register: server_path_media_store_remote_content_stat
  30. - name: Fail if media store directory doesn't look okay (lacking remote and local content)
  31. ansible.builtin.fail:
  32. msg: "{{ server_path_media_store }} contains neither local_content nor remote_content directories. It's most likely a mistake and is not a media store directory."
  33. when: "not server_path_media_store_local_content_stat.stat.exists and not server_path_media_store_remote_content_stat.stat.exists"
  34. # Actual import work
  35. - name: Ensure matrix-synapse is stopped
  36. ansible.builtin.service:
  37. name: matrix-synapse
  38. state: stopped
  39. enabled: false
  40. daemon_reload: true
  41. register: stopping_result
  42. # This can only work with local files, not if the media store is on Amazon S3,
  43. # as it won't be accessible in such a case.
  44. - name: Ensure provided media store directory is synchronized
  45. ansible.posix.synchronize:
  46. src: "{{ server_path_media_store }}/"
  47. dest: "{{ matrix_synapse_media_store_path }}"
  48. delete: true
  49. # It's wasteful to preserve owner/group now. We chown below anyway.
  50. owner: false
  51. group: false
  52. times: true
  53. delegate_to: "{{ inventory_hostname }}"
  54. # This is for the generic case and fails in other cases (remote file systems),
  55. # because in such cases the base path (matrix_synapse_media_store_path) is a mount point.
  56. - name: Ensure media store permissions are correct (generic case)
  57. ansible.builtin.file:
  58. path: "{{ matrix_synapse_media_store_path }}"
  59. owner: "{{ matrix_synapse_uid }}"
  60. group: "{{ matrix_synapse_gid }}"
  61. recurse: true
  62. when: "not matrix_s3_media_store_enabled | bool"
  63. # We don't chown for Goofys, because due to the way it's mounted,
  64. # all files become owned by whoever needs to own them.
  65. - name: Ensure Synapse is started (if it previously was)
  66. ansible.builtin.service:
  67. name: "{{ item }}"
  68. state: started
  69. daemon_reload: true
  70. when: "stopping_result.changed"
  71. with_items:
  72. - matrix-synapse