Matrix Docker Ansible eploy
Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 

84 righe
3.0 KiB

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