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

94 строки
3.5 KiB

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