Add matrix_synapse_uid, matrix_synapse_gid and matrix_synapse_username

This commit is contained in:
Slavi Pantaleev 2023-02-17 17:16:50 +02:00
parent 154d077ec7
commit 632026513e
19 changed files with 51 additions and 39 deletions

View File

@ -3071,6 +3071,10 @@ matrix_client_cinny_self_check_validate_certificates: "{{ false if matrix_playbo
matrix_synapse_enabled: "{{ matrix_homeserver_implementation == 'synapse' }}" matrix_synapse_enabled: "{{ matrix_homeserver_implementation == 'synapse' }}"
matrix_synapse_username: "{{ matrix_user_username }}"
matrix_synapse_uid: "{{ matrix_user_uid }}"
matrix_synapse_gid: "{{ matrix_user_gid }}"
matrix_synapse_container_image_self_build: "{{ matrix_architecture not in ['arm64', 'amd64'] }}" matrix_synapse_container_image_self_build: "{{ matrix_architecture not in ['arm64', 'amd64'] }}"
# When ma1sd is enabled, we can use it to validate phone numbers. It's something that the homeserver cannot do by itself. # When ma1sd is enabled, we can use it to validate phone numbers. It's something that the homeserver cannot do by itself.

View File

@ -4,6 +4,10 @@
matrix_synapse_enabled: true matrix_synapse_enabled: true
matrix_synapse_username: ''
matrix_synapse_uid: ''
matrix_synapse_gid: ''
matrix_synapse_container_image_self_build: false matrix_synapse_container_image_self_build: false
matrix_synapse_container_image_self_build_repo: "https://github.com/matrix-org/synapse.git" matrix_synapse_container_image_self_build_repo: "https://github.com/matrix-org/synapse.git"

View File

@ -6,8 +6,8 @@
dest: "{{ matrix_synapse_ext_path }}/matrix_e2ee_filter.py" dest: "{{ matrix_synapse_ext_path }}/matrix_e2ee_filter.py"
force: true force: true
mode: 0440 mode: 0440
owner: "{{ matrix_user_username }}" owner: "{{ matrix_synapse_uid }}"
group: "{{ matrix_user_groupname }}" group: "{{ matrix_synapse_gid }}"
register: result register: result
retries: "{{ devture_playbook_help_geturl_retries_count }}" retries: "{{ devture_playbook_help_geturl_retries_count }}"
delay: "{{ devture_playbook_help_geturl_retries_delay }}" delay: "{{ devture_playbook_help_geturl_retries_delay }}"

View File

@ -11,7 +11,7 @@
version: "{{ matrix_synapse_ext_spam_checker_mjolnir_antispam_git_version }}" version: "{{ matrix_synapse_ext_spam_checker_mjolnir_antispam_git_version }}"
dest: "{{ matrix_synapse_ext_path }}/mjolnir" dest: "{{ matrix_synapse_ext_path }}/mjolnir"
become: true become: true
become_user: "{{ matrix_user_username }}" become_user: "{{ matrix_synapse_username }}"
- ansible.builtin.set_fact: - ansible.builtin.set_fact:
matrix_synapse_spam_checker: > matrix_synapse_spam_checker: >

View File

@ -11,8 +11,8 @@
dest: "{{ matrix_synapse_ext_path }}/rest_auth_provider.py" dest: "{{ matrix_synapse_ext_path }}/rest_auth_provider.py"
force: true force: true
mode: 0440 mode: 0440
owner: "{{ matrix_user_username }}" owner: "{{ matrix_synapse_uid }}"
group: "{{ matrix_user_groupname }}" group: "{{ matrix_synapse_gid }}"
register: result register: result
retries: "{{ devture_playbook_help_geturl_retries_count }}" retries: "{{ devture_playbook_help_geturl_retries_count }}"
delay: "{{ devture_playbook_help_geturl_retries_delay }}" delay: "{{ devture_playbook_help_geturl_retries_delay }}"

View File

@ -12,8 +12,8 @@
path: "{{ item }}" path: "{{ item }}"
state: directory state: directory
mode: 0750 mode: 0750
owner: "{{ matrix_user_username }}" owner: "{{ matrix_synapse_uid }}"
group: "{{ matrix_user_groupname }}" group: "{{ matrix_synapse_gid }}"
with_items: with_items:
- "{{ matrix_synapse_ext_s3_storage_provider_base_path }}" - "{{ matrix_synapse_ext_s3_storage_provider_base_path }}"
- "{{ matrix_synapse_ext_s3_storage_provider_bin_path }}" - "{{ matrix_synapse_ext_s3_storage_provider_bin_path }}"

View File

@ -16,8 +16,8 @@
dest: "{{ matrix_synapse_ext_path }}/shared_secret_authenticator.py" dest: "{{ matrix_synapse_ext_path }}/shared_secret_authenticator.py"
force: true force: true
mode: 0440 mode: 0440
owner: "{{ matrix_user_username }}" owner: "{{ matrix_synapse_uid }}"
group: "{{ matrix_user_groupname }}" group: "{{ matrix_synapse_gid }}"
register: result register: result
retries: "{{ devture_playbook_help_geturl_retries_count }}" retries: "{{ devture_playbook_help_geturl_retries_count }}"
delay: "{{ devture_playbook_help_geturl_retries_delay }}" delay: "{{ devture_playbook_help_geturl_retries_delay }}"

View File

@ -16,7 +16,7 @@
version: "{{ matrix_synapse_ext_spam_checker_synapse_simple_antispam_git_version }}" version: "{{ matrix_synapse_ext_spam_checker_synapse_simple_antispam_git_version }}"
dest: "{{ matrix_synapse_ext_path }}/synapse-simple-antispam" dest: "{{ matrix_synapse_ext_path }}/synapse-simple-antispam"
become: true become: true
become_user: "{{ matrix_user_username }}" become_user: "{{ matrix_synapse_username }}"
- ansible.builtin.set_fact: - ansible.builtin.set_fact:
matrix_synapse_modules: > matrix_synapse_modules: >

View File

@ -27,8 +27,8 @@
path: "{{ matrix_s3_media_store_path }}" path: "{{ matrix_s3_media_store_path }}"
state: directory state: directory
mode: 0750 mode: 0750
owner: "{{ matrix_user_username }}" owner: "{{ matrix_synapse_uid }}"
group: "{{ matrix_user_groupname }}" group: "{{ matrix_synapse_gid }}"
when: "not local_path_matrix_s3_media_store_path_stat.failed and not local_path_matrix_s3_media_store_path_stat.stat.exists" when: "not local_path_matrix_s3_media_store_path_stat.failed and not local_path_matrix_s3_media_store_path_stat.stat.exists"
- name: Ensure goofys environment variables file created - name: Ensure goofys environment variables file created

View File

@ -66,8 +66,8 @@
- name: Ensure media store permissions are correct (generic case) - name: Ensure media store permissions are correct (generic case)
ansible.builtin.file: ansible.builtin.file:
path: "{{ matrix_synapse_media_store_path }}" path: "{{ matrix_synapse_media_store_path }}"
owner: "{{ matrix_user_username }}" owner: "{{ matrix_synapse_uid }}"
group: "{{ matrix_user_groupname }}" group: "{{ matrix_synapse_gid }}"
recurse: true recurse: true
when: "not matrix_s3_media_store_enabled | bool" when: "not matrix_s3_media_store_enabled | bool"

View File

@ -7,7 +7,7 @@
ansible.builtin.set_fact: ansible.builtin.set_fact:
matrix_synapse_rust_synapse_compress_state_compress_room_command: >- matrix_synapse_rust_synapse_compress_state_compress_room_command: >-
{{ devture_systemd_docker_base_host_command_docker }} run --rm --name matrix-rust-synapse-compress-state-compress-room {{ devture_systemd_docker_base_host_command_docker }} run --rm --name matrix-rust-synapse-compress-state-compress-room
--user={{ matrix_user_uid }}:{{ matrix_user_gid }} --user={{ matrix_synapse_uid }}:{{ matrix_synapse_gid }}
--cap-drop=ALL --cap-drop=ALL
--network={{ matrix_docker_network }} --network={{ matrix_docker_network }}
--mount type=bind,src={{ matrix_synapse_rust_synapse_compress_state_base_path }},dst=/work --mount type=bind,src={{ matrix_synapse_rust_synapse_compress_state_base_path }},dst=/work

View File

@ -39,8 +39,8 @@
path: "{{ matrix_synapse_rust_synapse_compress_state_base_path }}" path: "{{ matrix_synapse_rust_synapse_compress_state_base_path }}"
state: directory state: directory
mode: 0750 mode: 0750
owner: "{{ matrix_user_username }}" owner: "{{ matrix_synapse_uid }}"
group: "{{ matrix_user_groupname }}" group: "{{ matrix_synapse_gid }}"
- name: Ensure rust-synapse-compress-state image is pulled - name: Ensure rust-synapse-compress-state image is pulled
community.docker.docker_image: community.docker.docker_image:

View File

@ -5,8 +5,8 @@
path: "{{ item.path }}" path: "{{ item.path }}"
state: directory state: directory
mode: 0750 mode: 0750
owner: "{{ matrix_user_username }}" owner: "{{ matrix_synapse_uid }}"
group: "{{ matrix_user_groupname }}" group: "{{ matrix_synapse_gid }}"
with_items: with_items:
- {path: "{{ matrix_synapse_config_dir_path }}", when: true} - {path: "{{ matrix_synapse_config_dir_path }}", when: true}
- {path: "{{ matrix_synapse_ext_path }}", when: true} - {path: "{{ matrix_synapse_ext_path }}", when: true}

View File

@ -14,8 +14,8 @@
path: "{{ matrix_synapse_media_store_path }}" path: "{{ matrix_synapse_media_store_path }}"
state: directory state: directory
mode: 0750 mode: 0750
owner: "{{ matrix_user_username }}" owner: "{{ matrix_synapse_uid }}"
group: "{{ matrix_user_groupname }}" group: "{{ matrix_synapse_gid }}"
when: "not local_path_media_store_stat.failed and not local_path_media_store_stat.stat.exists" when: "not local_path_media_store_stat.failed and not local_path_media_store_stat.stat.exists"
- when: "matrix_synapse_container_image_self_build | bool" - when: "matrix_synapse_container_image_self_build | bool"
@ -27,7 +27,7 @@
version: "{{ matrix_synapse_docker_image.split(':')[1] }}" version: "{{ matrix_synapse_docker_image.split(':')[1] }}"
force: "yes" force: "yes"
become: true become: true
become_user: "{{ matrix_user_username }}" become_user: "{{ matrix_synapse_username }}"
register: matrix_synapse_git_pull_results register: matrix_synapse_git_pull_results
- name: Check if Synapse Docker image exists - name: Check if Synapse Docker image exists
@ -68,8 +68,8 @@
ansible.builtin.template: ansible.builtin.template:
src: "{{ role_path }}/templates/synapse/customizations/Dockerfile.j2" src: "{{ role_path }}/templates/synapse/customizations/Dockerfile.j2"
dest: "{{ matrix_synapse_customized_docker_src_files_path }}/Dockerfile" dest: "{{ matrix_synapse_customized_docker_src_files_path }}/Dockerfile"
owner: "{{ matrix_user_username }}" owner: "{{ matrix_synapse_uid }}"
group: "{{ matrix_user_groupname }}" group: "{{ matrix_synapse_gid }}"
mode: 0640 mode: 0640
- name: Ensure customized Docker image for Synapse is built - name: Ensure customized Docker image for Synapse is built
@ -98,7 +98,7 @@
docker run docker run
--rm --rm
--name=matrix-config --name=matrix-config
--user={{ matrix_user_uid }}:{{ matrix_user_gid }} --user={{ matrix_synapse_uid }}:{{ matrix_synapse_gid }}
--cap-drop=ALL --cap-drop=ALL
--mount type=bind,src={{ matrix_synapse_config_dir_path }},dst=/data --mount type=bind,src={{ matrix_synapse_config_dir_path }},dst=/data
-e SYNAPSE_CONFIG_PATH=/data/homeserver.yaml -e SYNAPSE_CONFIG_PATH=/data/homeserver.yaml
@ -113,8 +113,8 @@
content: "{{ matrix_synapse_configuration | to_nice_yaml(indent=2, width=999999) }}" content: "{{ matrix_synapse_configuration | to_nice_yaml(indent=2, width=999999) }}"
dest: "{{ matrix_synapse_config_dir_path }}/homeserver.yaml" dest: "{{ matrix_synapse_config_dir_path }}/homeserver.yaml"
mode: 0644 mode: 0644
owner: "{{ matrix_user_username }}" owner: "{{ matrix_synapse_uid }}"
group: "{{ matrix_user_groupname }}" group: "{{ matrix_synapse_gid }}"
- name: Ensure Synapse log config installed - name: Ensure Synapse log config installed
ansible.builtin.template: ansible.builtin.template:
@ -143,7 +143,7 @@
ansible.builtin.template: ansible.builtin.template:
src: "{{ role_path }}/templates/synapse/prometheus/external_prometheus.yml.example.j2" src: "{{ role_path }}/templates/synapse/prometheus/external_prometheus.yml.example.j2"
dest: "{{ matrix_synapse_base_path }}/external_prometheus.yml.example" dest: "{{ matrix_synapse_base_path }}/external_prometheus.yml.example"
owner: "{{ matrix_user_username }}" owner: "{{ matrix_synapse_uid }}"
group: "{{ matrix_user_groupname }}" group: "{{ matrix_synapse_gid }}"
mode: 0644 mode: 0644
when: matrix_synapse_metrics_proxying_enabled | bool when: matrix_synapse_metrics_proxying_enabled | bool

View File

@ -10,8 +10,8 @@
src: "{{ role_path }}/templates/synapse/worker.yaml.j2" src: "{{ role_path }}/templates/synapse/worker.yaml.j2"
dest: "{{ matrix_synapse_config_dir_path }}/{{ matrix_synapse_worker_config_file_name }}" dest: "{{ matrix_synapse_config_dir_path }}/{{ matrix_synapse_worker_config_file_name }}"
mode: 0644 mode: 0644
owner: "{{ matrix_user_username }}" owner: "{{ matrix_synapse_uid }}"
group: "{{ matrix_user_groupname }}" group: "{{ matrix_synapse_gid }}"
- name: Ensure systemd service exists for {{ matrix_synapse_worker_systemd_service_name }} - name: Ensure systemd service exists for {{ matrix_synapse_worker_systemd_service_name }}
ansible.builtin.template: ansible.builtin.template:

View File

@ -6,11 +6,15 @@
You need to define a required configuration setting (`{{ item }}`) for using Synapse. You need to define a required configuration setting (`{{ item }}`) for using Synapse.
when: "vars[item] == ''" when: "vars[item] == ''"
with_items: with_items:
- "matrix_synapse_macaroon_secret_key" - matrix_synapse_username
- "matrix_synapse_database_host" - matrix_synapse_uid
- "matrix_synapse_database_user" - matrix_synapse_gid
- "matrix_synapse_database_password" - matrix_synapse_container_network
- "matrix_synapse_database_database" - matrix_synapse_macaroon_secret_key
- matrix_synapse_database_host
- matrix_synapse_database_user
- matrix_synapse_database_password
- matrix_synapse_database_database
- name: Fail if asking for more than 1 instance of single-instance workers - name: Fail if asking for more than 1 instance of single-instance workers
ansible.builtin.fail: ansible.builtin.fail:

View File

@ -13,7 +13,7 @@ ExecStartPre=-{{ devture_systemd_docker_base_host_command_docker }} rm %n
ExecStart={{ devture_systemd_docker_base_host_command_docker }} run --rm --name %n \ ExecStart={{ devture_systemd_docker_base_host_command_docker }} run --rm --name %n \
--log-driver=none \ --log-driver=none \
--user={{ matrix_user_uid }}:{{ matrix_user_gid }} \ --user={{ matrix_synapse_uid }}:{{ matrix_synapse_gid }} \
--mount type=bind,src=/etc/passwd,dst=/etc/passwd,ro \ --mount type=bind,src=/etc/passwd,dst=/etc/passwd,ro \
--mount type=bind,src=/etc/group,dst=/etc/group,ro \ --mount type=bind,src=/etc/group,dst=/etc/group,ro \
--mount type=bind,src={{ matrix_s3_media_store_path }},dst=/s3,bind-propagation=shared \ --mount type=bind,src={{ matrix_s3_media_store_path }},dst=/s3,bind-propagation=shared \

View File

@ -18,7 +18,7 @@ ExecStartPre={{ devture_systemd_docker_base_host_command_docker }} create \
--rm \ --rm \
--name={{ matrix_synapse_worker_container_name }} \ --name={{ matrix_synapse_worker_container_name }} \
--log-driver=none \ --log-driver=none \
--user={{ matrix_user_uid }}:{{ matrix_user_gid }} \ --user={{ matrix_synapse_uid }}:{{ matrix_synapse_gid }} \
--cap-drop=ALL \ --cap-drop=ALL \
--read-only \ --read-only \
--tmpfs=/tmp:rw,noexec,nosuid,size={{ matrix_synapse_tmp_directory_size_mb }}m \ --tmpfs=/tmp:rw,noexec,nosuid,size={{ matrix_synapse_tmp_directory_size_mb }}m \

View File

@ -34,7 +34,7 @@ ExecStartPre={{ devture_systemd_docker_base_host_command_docker }} create \
--rm \ --rm \
--name=matrix-synapse \ --name=matrix-synapse \
--log-driver=none \ --log-driver=none \
--user={{ matrix_user_uid }}:{{ matrix_user_gid }} \ --user={{ matrix_synapse_uid }}:{{ matrix_synapse_gid }} \
--cap-drop=ALL \ --cap-drop=ALL \
--read-only \ --read-only \
--tmpfs=/tmp:rw,noexec,nosuid,size={{ matrix_synapse_tmp_directory_size_mb }}m \ --tmpfs=/tmp:rw,noexec,nosuid,size={{ matrix_synapse_tmp_directory_size_mb }}m \