parent
db686c3f8e
commit
efc78fb9d3
@ -0,0 +1,70 @@
|
||||
#
|
||||
# Tasks related to setting up Goofys
|
||||
#
|
||||
|
||||
- name: Ensure Goofys Docker image is pulled
|
||||
docker_image:
|
||||
name: "{{ docker_goofys_image }}"
|
||||
when: matrix_s3_media_store_enabled
|
||||
|
||||
# This will throw a Permission Denied error if already mounted
|
||||
- name: Check Matrix Goofys external storage mountpoint path
|
||||
stat: path="{{ matrix_synapse_media_store_path }}"
|
||||
register: local_path_matrix_synapse_media_store_path_stat
|
||||
ignore_errors: yes
|
||||
when: matrix_s3_media_store_enabled
|
||||
|
||||
- name: Ensure Matrix Goofys external storage mountpoint exists
|
||||
file:
|
||||
path: "{{ matrix_synapse_media_store_path }}"
|
||||
state: directory
|
||||
mode: 0750
|
||||
owner: "{{ matrix_user_uid }}"
|
||||
group: "{{ matrix_user_gid }}"
|
||||
when: "matrix_s3_media_store_enabled and not local_path_matrix_synapse_media_store_path_stat.failed and not local_path_matrix_synapse_media_store_path_stat.stat.exists"
|
||||
|
||||
- name: Ensure goofys environment variables file created
|
||||
template:
|
||||
src: "{{ role_path }}/templates/env/env-goofys.j2"
|
||||
dest: "{{ matrix_environment_variables_data_path }}/goofys"
|
||||
owner: root
|
||||
mode: 0600
|
||||
when: matrix_s3_media_store_enabled
|
||||
|
||||
- name: Ensure matrix-goofys.service installed
|
||||
template:
|
||||
src: "{{ role_path }}/templates/systemd/matrix-goofys.service.j2"
|
||||
dest: "/etc/systemd/system/matrix-goofys.service"
|
||||
mode: 0644
|
||||
when: matrix_s3_media_store_enabled
|
||||
|
||||
#
|
||||
# Tasks related to getting rid of goofys (if it was previously enabled)
|
||||
#
|
||||
|
||||
- name: Check existence of matrix-goofys service
|
||||
stat: path="/etc/systemd/system/matrix-goofys.service"
|
||||
register: matrix_goofys_service_stat
|
||||
|
||||
- name: Ensure matrix-goofys is stopped
|
||||
service: name=matrix-goofys state=stopped daemon_reload=yes
|
||||
register: stopping_result
|
||||
when: "not matrix_s3_media_store_enabled and matrix_goofys_service_stat.stat.exists"
|
||||
|
||||
- name: Ensure matrix-goofys.service doesn't exist
|
||||
file:
|
||||
path: "/etc/systemd/system/matrix-goofys.service"
|
||||
state: absent
|
||||
when: "not matrix_s3_media_store_enabled and matrix_goofys_service_stat.stat.exists"
|
||||
|
||||
- name: Ensure goofys environment variables file doesn't exist
|
||||
file:
|
||||
path: "{{ matrix_environment_variables_data_path }}/goofys"
|
||||
state: absent
|
||||
when: "not matrix_s3_media_store_enabled"
|
||||
|
||||
- name: Ensure Goofys Docker image doesn't exist
|
||||
docker_image:
|
||||
name: "{{ docker_goofys_image }}"
|
||||
state: absent
|
||||
when: "not matrix_s3_media_store_enabled"
|
@ -0,0 +1,2 @@
|
||||
AWS_ACCESS_KEY={{ matrix_s3_media_store_aws_access_key }}
|
||||
AWS_SECRET_KEY={{ matrix_s3_media_store_aws_secret_key }}
|
@ -0,0 +1,32 @@
|
||||
[Unit]
|
||||
Description=Matrix Goofys media store
|
||||
After=docker.service
|
||||
Requires=docker.service
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
ExecStartPre=-/usr/bin/docker kill %n
|
||||
ExecStartPre=-/usr/bin/docker rm %n
|
||||
ExecStart=/usr/bin/docker run --rm --name %n \
|
||||
--user={{ matrix_user_uid }}:{{ matrix_user_gid }} \
|
||||
-v /etc/passwd:/etc/passwd:ro \
|
||||
-v /etc/group:/etc/group:ro \
|
||||
--security-opt apparmor:unconfined \
|
||||
--cap-add mknod \
|
||||
--cap-add sys_admin \
|
||||
--device=/dev/fuse \
|
||||
-v {{ matrix_synapse_media_store_path }}:/s3:shared \
|
||||
--env-file={{ matrix_environment_variables_data_path }}/goofys \
|
||||
--entrypoint /bin/sh \
|
||||
{{ docker_goofys_image }} \
|
||||
-c 'goofys -f --storage-class=STANDARD_IA --region {{ matrix_s3_media_store_region }} --stat-cache-ttl 60m0s --type-cache-ttl 60m0s --dir-mode 0700 --file-mode 0700 {{ matrix_s3_media_store_bucket_name }} /s3'
|
||||
TimeoutStartSec=5min
|
||||
ExecStop=-/usr/bin/docker stop %n
|
||||
ExecStop=-/usr/bin/docker kill %n
|
||||
ExecStop=-/usr/bin/docker rm %n
|
||||
ExecStop=-/bin/fusermount -u {{ matrix_synapse_media_store_path }}
|
||||
Restart=always
|
||||
RestartSec=5
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
@ -1,35 +0,0 @@
|
||||
[Unit]
|
||||
Description=Matrix S3fs media store
|
||||
After=docker.service
|
||||
Requires=docker.service
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
ExecStartPre=-/usr/bin/docker kill %n
|
||||
ExecStartPre=-/usr/bin/docker rm %n
|
||||
ExecStartPre=-/usr/bin/mkdir /tmp/matrix-s3fs-cache
|
||||
ExecStart=/usr/bin/docker run --rm --name %n \
|
||||
-v {{ matrix_base_data_path }}/s3fs-credentials:/s3fs-credentials \
|
||||
--security-opt apparmor:unconfined \
|
||||
--cap-add mknod \
|
||||
--cap-add sys_admin \
|
||||
--device=/dev/fuse \
|
||||
-v {{ matrix_synapse_media_store_path }}:/media-store:shared \
|
||||
-v /tmp/matrix-s3fs-cache:/s3fs-cache \
|
||||
{{ docker_s3fs_image }} \
|
||||
/usr/bin/s3fs -f \
|
||||
-o allow_other \
|
||||
-o use_cache=/s3fs-cache \
|
||||
-o storage_class=standard_ia \
|
||||
-o passwd_file=/s3fs-credentials \
|
||||
{{ matrix_s3_media_store_bucket_name }} /media-store
|
||||
TimeoutStartSec=5min
|
||||
ExecStop=-/usr/bin/docker stop %n
|
||||
ExecStop=-/usr/bin/docker kill %n
|
||||
ExecStop=-/usr/bin/docker rm %n
|
||||
ExecStop=-/usr/bin/rm -rf /tmp/matrix-s3fs-cache
|
||||
Restart=always
|
||||
RestartSec=5
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
Loading…
Reference in new issue