Matrix Docker Ansible eploy
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

83 lines
3.3 KiB

  1. ---
  2. - name: Fail if playbook called incorrectly
  3. fail: msg="The `local_path_media_store` variable needs to be provided to this playbook, via --extra-vars"
  4. when: "local_path_media_store is not defined or local_path_media_store.startswith('<')"
  5. - name: Check if the provided media store directory exists
  6. stat: path="{{ local_path_media_store }}"
  7. delegate_to: 127.0.0.1
  8. become: false
  9. register: local_path_media_store_stat
  10. - name: Fail if provided media store directory doesn't exist on the local machine
  11. fail: msg="{{ local_path_media_store }} cannot be found on the local machine"
  12. when: "not local_path_media_store_stat.stat.exists or not local_path_media_store_stat.stat.isdir"
  13. - name: Check if media store contains local_content
  14. stat: path="{{ local_path_media_store }}/local_content"
  15. delegate_to: 127.0.0.1
  16. become: false
  17. register: local_path_media_store_local_content_stat
  18. - name: Check if media store contains remote_content
  19. stat: path="{{ local_path_media_store }}/remote_content"
  20. delegate_to: 127.0.0.1
  21. become: false
  22. register: local_path_media_store_remote_content_stat
  23. - name: Fail if media store directory doesn't look okay (lacking remote and local content)
  24. fail: msg="{{ local_path_media_store }} contains neither local_content nor remote_content. It's most likely a mistake and is not a media store directory."
  25. when: "not local_path_media_store_local_content_stat.stat.exists and not local_path_media_store_remote_content_stat.stat.exists"
  26. - name: Ensure matrix-synapse is stopped
  27. service: name=matrix-synapse state=stopped daemon_reload=yes
  28. register: stopping_result
  29. - name: Ensure provided media store directory is copied to the server
  30. synchronize:
  31. src: "{{ local_path_media_store }}/"
  32. dest: "{{ matrix_synapse_media_store_path }}"
  33. delete: yes
  34. # It's wasteful to preserve owner/group now. We chown below anyway.
  35. owner: no
  36. group: no
  37. # The default of times=yes does not work when s3fs is used.
  38. times: "{{ False if matrix_s3_media_store_enabled else True }}"
  39. perms: "{{ False if matrix_s3_media_store_enabled else True }}"
  40. # This is for the generic case and fails for remote file systems,
  41. # because the base path (matrix_synapse_media_store_path) is a mount point.
  42. - name: Ensure media store permissions are correct (generic case)
  43. file:
  44. path: "{{ matrix_synapse_media_store_path }}"
  45. owner: "{{ matrix_user_username }}"
  46. group: "{{ matrix_user_username }}"
  47. recurse: yes
  48. when: "not matrix_s3_media_store_enabled"
  49. - name: Determine media store subdirectories
  50. find: paths="{{ local_path_media_store }}" file_type=directory
  51. delegate_to: 127.0.0.1
  52. become: false
  53. register: media_store_directories_result
  54. when: "matrix_s3_media_store_enabled"
  55. # This is the s3fs special case. We chown the subdirectories one by one,
  56. # without touching the base directory.
  57. - name: Ensure media store permissions are correct (s3fs)
  58. file:
  59. path: "{{ matrix_synapse_media_store_path }}/{{ item.path|basename }}"
  60. owner: "{{ matrix_user_username }}"
  61. group: "{{ matrix_user_username }}"
  62. recurse: yes
  63. with_items: "{{ media_store_directories_result.files }}"
  64. when: "matrix_s3_media_store_enabled"
  65. - name: Ensure Matrix Synapse is started (if it previously was)
  66. service: name="{{ item }}" state=started daemon_reload=yes
  67. when: stopping_result.changed
  68. with_items:
  69. - matrix-synapse
  70. - matrix-nginx-proxy