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.
 
 

85 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|bool
  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. enabled: false
  37. daemon_reload: true
  38. register: stopping_result
  39. # This can only work with local files, not if the media store is on Amazon S3,
  40. # as it won't be accessible in such a case.
  41. - name: Ensure provided media store directory is synchronized
  42. synchronize:
  43. src: "{{ server_path_media_store }}/"
  44. dest: "{{ matrix_synapse_media_store_path }}"
  45. delete: true
  46. # It's wasteful to preserve owner/group now. We chown below anyway.
  47. owner: false
  48. group: false
  49. times: true
  50. delegate_to: "{{ inventory_hostname }}"
  51. # This is for the generic case and fails in other cases (remote file systems),
  52. # because in such cases the base path (matrix_synapse_media_store_path) is a mount point.
  53. - name: Ensure media store permissions are correct (generic case)
  54. file:
  55. path: "{{ matrix_synapse_media_store_path }}"
  56. owner: "{{ matrix_user_username }}"
  57. group: "{{ matrix_user_groupname }}"
  58. recurse: true
  59. when: "not matrix_s3_media_store_enabled|bool"
  60. # We don't chown for Goofys, because due to the way it's mounted,
  61. # all files become owned by whoever needs to own them.
  62. - name: Ensure Synapse is started (if it previously was)
  63. service:
  64. name: "{{ item }}"
  65. state: started
  66. daemon_reload: true
  67. when: "stopping_result.changed"
  68. with_items:
  69. - matrix-synapse