2017-07-31 20:07:30 +00:00
---
- name : Fail if playbook called incorrectly
fail : msg="The `local_path_media_store` variable needs to be provided to this playbook, via --extra-vars"
when : "local_path_media_store is not defined or local_path_media_store.startswith('<')"
- name : Check if the provided media store directory exists
stat : path="{{ local_path_media_store }}"
delegate_to : 127.0 .0 .1
become : false
register : local_path_media_store_stat
2017-09-07 09:23:22 +00:00
- name : Fail if provided media store directory doesn't exist on the local machine
fail : msg="{{ local_path_media_store }} cannot be found on the local machine"
2017-07-31 20:07:30 +00:00
when : "not local_path_media_store_stat.stat.exists or not local_path_media_store_stat.stat.isdir"
2017-09-07 09:12:31 +00:00
- name : Check if media store contains local_content
stat : path="{{ local_path_media_store }}/local_content"
delegate_to : 127.0 .0 .1
become : false
register : local_path_media_store_local_content_stat
- name : Check if media store contains remote_content
stat : path="{{ local_path_media_store }}/remote_content"
delegate_to : 127.0 .0 .1
become : false
register : local_path_media_store_remote_content_stat
2017-09-07 09:23:22 +00:00
- name : Fail if media store directory doesn't look okay (lacking remote and local content)
2017-09-07 09:12:31 +00:00
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."
when : "not local_path_media_store_local_content_stat.stat.exists and not local_path_media_store_remote_content_stat.stat.exists"
2017-07-31 20:07:30 +00:00
- name : Ensure matrix-synapse is stopped
service : name=matrix-synapse state=stopped daemon_reload=yes
register : stopping_result
2017-09-07 09:23:22 +00:00
- name : Ensure provided media store directory is copied to the server
2017-07-31 20:07:30 +00:00
synchronize :
src : "{{ local_path_media_store }}/"
2017-09-07 09:12:31 +00:00
dest : "{{ matrix_synapse_media_store_path }}"
2017-07-31 20:07:30 +00:00
delete : yes
2017-09-07 09:27:32 +00:00
# It's wasteful to preserve owner/group now. We chown below anyway.
owner : no
group : no
2017-09-07 15:26:41 +00:00
times : "{{ False if matrix_s3_media_store_enabled else True }}"
perms : "{{ False if matrix_s3_media_store_enabled else True }}"
2017-07-31 20:07:30 +00:00
2018-02-20 19:36:08 +00:00
# This is for the generic case and fails in other cases (remote file systems),
# because in such cases the base path (matrix_synapse_media_store_path) is a mount point.
2017-09-07 15:26:41 +00:00
- name : Ensure media store permissions are correct (generic case)
2017-09-07 09:23:22 +00:00
file :
path : "{{ matrix_synapse_media_store_path }}"
owner : "{{ matrix_user_username }}"
group : "{{ matrix_user_username }}"
2017-09-07 09:24:04 +00:00
recurse : yes
2017-09-07 15:26:41 +00:00
when : "not matrix_s3_media_store_enabled"
2018-02-20 19:36:08 +00:00
# We don't chown for Goofys, because due to the way it's mounted,
# all files become owned by whoever needs to own them.
2017-09-07 09:23:22 +00:00
2017-07-31 20:07:30 +00:00
- name : Ensure Matrix Synapse is started (if it previously was)
service : name="{{ item }}" state=started daemon_reload=yes
when : stopping_result.changed
with_items :
- matrix-synapse
- matrix-nginx-proxy