Skip to content

Commit aae6b8e

Browse files
playbook modified to be compatible with docker user namspaces
1 parent 0aeb9a6 commit aae6b8e

File tree

20 files changed

+120
-31
lines changed

20 files changed

+120
-31
lines changed

group_vars/matrix_servers

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
# #
1616
########################################################################
1717

18+
matrix_playbook_userns_enabled: false
19+
matrix_playbook_userns_offset: 0
20+
1821
# Controls whether to install Docker or not
1922
# Also see `devture_docker_sdk_for_python_installation_enabled`.
2023
matrix_playbook_docker_installation_enabled: true
@@ -3888,6 +3891,8 @@ exim_relay_base_path: "{{ matrix_base_data_path }}/exim-relay"
38883891

38893892
exim_relay_uid: "{{ matrix_user_uid }}"
38903893
exim_relay_gid: "{{ matrix_user_gid }}"
3894+
exim_relay_docker_userns_enabled: "{{ matrix_playbook_userns_enabled }}"
3895+
exim_relay_docker_userns_offset: "{{ matrix_playbook_userns_offset }}"
38913896

38923897
exim_relay_hostname: "{{ matrix_server_fqn_matrix }}"
38933898

@@ -4097,9 +4102,12 @@ postgres_identifier: matrix-postgres
40974102
postgres_architecture: "{{ matrix_architecture }}"
40984103

40994104
postgres_base_path: "{{ matrix_base_data_path }}/postgres"
4105+
postgres_passwd_file_path : "{{ matrix_playbook_passwd_file_path }}"
41004106

41014107
postgres_uid: "{{ matrix_user_uid }}"
41024108
postgres_gid: "{{ matrix_user_gid }}"
4109+
postgres_docker_userns_enabled: "{{ matrix_playbook_userns_enabled }}"
4110+
postgres_docker_userns_offset: "{{ matrix_playbook_userns_offset }}"
41034111

41044112
postgres_connection_username: matrix
41054113
postgres_db_name: matrix
@@ -4507,6 +4515,8 @@ ntfy_base_path: "{{ matrix_base_data_path }}/ntfy"
45074515

45084516
ntfy_uid: "{{ matrix_user_uid }}"
45094517
ntfy_gid: "{{ matrix_user_gid }}"
4518+
ntfy_docker_userns_enabled: "{{ matrix_playbook_userns_enabled }}"
4519+
ntfy_docker_userns_offset: "{{ matrix_playbook_userns_offset }}"
45104520

45114521
ntfy_hostname: "{{ matrix_server_fqn_ntfy }}"
45124522

@@ -4545,6 +4555,8 @@ valkey_identifier: matrix-valkey
45454555

45464556
valkey_uid: "{{ matrix_user_uid }}"
45474557
valkey_gid: "{{ matrix_user_gid }}"
4558+
valkey_docker_userns_enabled: "{{ matrix_playbook_userns_enabled }}"
4559+
valkey_docker_userns_offset: "{{ matrix_playbook_userns_offset }}"
45484560

45494561
valkey_base_path: "{{ matrix_base_data_path }}/valkey"
45504562

@@ -4798,6 +4810,11 @@ matrix_synapse_enabled: "{{ matrix_homeserver_implementation == 'synapse' }}"
47984810
matrix_synapse_username: "{{ matrix_user_username }}"
47994811
matrix_synapse_uid: "{{ matrix_user_uid }}"
48004812
matrix_synapse_gid: "{{ matrix_user_gid }}"
4813+
matrix_synapse_docker_userns_enabled: "{{ matrix_playbook_userns_enabled }}"
4814+
matrix_synapse_docker_userns_offset: "{{ matrix_playbook_userns_offset }}"
4815+
4816+
matrix_synapse_passwd_file_path: "{{ matrix_playbook_passwd_file_path }}"
4817+
matrix_synapse_group_file_path: "{{ matrix_playbook_group_file_path }}"
48014818

48024819
matrix_synapse_federation_enabled: "{{ matrix_homeserver_federation_enabled }}"
48034820

@@ -6205,6 +6222,8 @@ traefik_base_path: "{{ matrix_base_data_path }}/traefik"
62056222

62066223
traefik_uid: "{{ matrix_user_uid }}"
62076224
traefik_gid: "{{ matrix_user_gid }}"
6225+
traefik_docker_userns_enabled: "{{ matrix_playbook_userns_enabled }}"
6226+
traefik_docker_userns_offset: "{{ matrix_playbook_userns_offset }}"
62086227

62096228
# It's common for setups to deal with large file uploads which may take longer than the default readTimeout (60s).
62106229
# This override (for the `web` entrypoint) also cascades to overriding the `web-secure` entrypoint and the `matrix-federation` entrypoint.
@@ -6217,7 +6236,7 @@ traefik_additional_entrypoints_auto: |
62176236
([matrix_playbook_internal_matrix_client_api_traefik_entrypoint_definition] if matrix_playbook_internal_matrix_client_api_traefik_entrypoint_enabled else [])
62186237
}}
62196238

6220-
traefik_config_providers_docker_endpoint: "{{ container_socket_proxy_endpoint if container_socket_proxy_enabled else 'unix:///var/run/docker.sock' }}"
6239+
traefik_config_providers_docker_endpoint: "{{ container_socket_proxy_endpoint if container_socket_proxy_enabled else ('unix:///var/run/docker.sock' if not matrix_playbook_userns_enabled else 'unix:///var/run/docker-userns.sock') }}"
62216240

62226241
traefik_container_image_registry_prefix_upstream: "{{ matrix_container_global_registry_prefix_override if matrix_container_global_registry_prefix_override else traefik_container_image_registry_prefix_upstream_default }}"
62236242

roles/custom/matrix-base/defaults/main.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,11 @@ matrix_user_groupname: "matrix"
180180
# To use a specific user/group ID, override these variables.
181181
matrix_user_uid: ~
182182
matrix_user_gid: ~
183+
matrix_container_user_host_uid: ''
184+
matrix_container_user_host_gid: ''
185+
186+
matrix_playbook_userns_enabled: false
187+
matrix_playbook_userns_offset: 0
183188

184189
matrix_base_data_path: "/matrix"
185190
matrix_base_data_path_mode: "750"

roles/custom/matrix-base/tasks/setup_matrix_user.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@
2323
system: true
2424
register: matrix_user
2525

26-
- name: Initialize matrix_user_uid and matrix_user_gid
26+
- name: Initialize matrix_user_uid, matrix_user_gid, matrix_container_user_host_uid and matrix_container_user_host_gid
2727
ansible.builtin.set_fact:
2828
matrix_user_uid: "{{ matrix_user.uid }}"
2929
matrix_user_gid: "{{ matrix_group.gid }}"
30+
matrix_container_user_host_uid: "{{ matrix_user_uid if not matrix_playbook_userns_enabled else (matrix_user_uid | int + matrix_playbook_userns_offset) | string }}"
31+
matrix_container_user_host_gid: "{{ matrix_user_gid if not matrix_playbook_userns_enabled else (matrix_user_gid | int + matrix_playbook_userns_offset) | string }}"

roles/custom/matrix-client-element/tasks/setup_install.yml

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,19 +75,19 @@
7575
content: "{{ matrix_client_element_configuration | to_nice_json }}"
7676
dest: "{{ matrix_client_element_data_path }}/config.json"
7777
mode: 0644
78-
owner: "{{ matrix_user_username }}"
79-
group: "{{ matrix_user_groupname }}"
78+
owner: "{{ matrix_container_user_host_uid }}"
79+
group: "{{ matrix_container_user_host_gid }}"
8080

8181
- name: Ensure Element location sharing map style installed
8282
when: matrix_client_element_location_sharing_enabled | bool
8383
ansible.builtin.copy:
8484
content: "{{ matrix_client_element_location_sharing_map_style | to_nice_json }}"
8585
dest: "{{ matrix_client_element_data_path }}/map_style.json"
8686
mode: 0644
87-
owner: "{{ matrix_user_username }}"
88-
group: "{{ matrix_user_groupname }}"
87+
owner: "{{ matrix_container_user_host_uid }}"
88+
group: "{{ matrix_container_user_host_gid }}"
8989

90-
- name: Ensure Element Web config files installed
90+
- name: Ensure Element Web template files installed
9191
ansible.builtin.template:
9292
src: "{{ item.src }}"
9393
dest: "{{ matrix_client_element_data_path }}/{{ item.name }}"
@@ -97,6 +97,16 @@
9797
with_items:
9898
- {src: "{{ role_path }}/templates/labels.j2", name: "labels"}
9999
- {src: "{{ role_path }}/templates/env.j2", name: "env"}
100+
when: "item.src is not none"
101+
102+
- name: Ensure Element Web config files installed
103+
ansible.builtin.template:
104+
src: "{{ item.src }}"
105+
dest: "{{ matrix_client_element_data_path }}/{{ item.name }}"
106+
mode: 0644
107+
owner: "{{ matrix_container_user_host_uid }}"
108+
group: "{{ matrix_container_user_host_gid }}"
109+
with_items:
100110
- {src: "{{ matrix_client_element_page_template_welcome_path }}", name: "welcome.html"}
101111
- {src: "{{ matrix_client_element_embedded_pages_home_path }}", name: "home.html"}
102112
when: "item.src is not none"

roles/custom/matrix-coturn/tasks/setup_install.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@
105105
src: "{{ role_path }}/templates/turnserver.conf.j2"
106106
dest: "{{ matrix_coturn_config_path }}"
107107
mode: 0644
108-
owner: "{{ matrix_user_username }}"
109-
group: "{{ matrix_user_groupname }}"
108+
owner: "{{ matrix_container_user_host_uid }}"
109+
group: "{{ matrix_container_user_host_gid }}"
110110

111111
- name: Ensure coturn network is created in Docker
112112
when: matrix_coturn_container_network not in ['', 'host']

roles/custom/matrix-static-files/tasks/install.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
---
77

8-
- name: Ensure matrix-static-files paths exist
8+
- name: Ensure matrix-static-files base path exist
99
ansible.builtin.file:
1010
path: "{{ item.path }}"
1111
state: directory
@@ -14,6 +14,16 @@
1414
group: "{{ matrix_user_groupname }}"
1515
with_items:
1616
- {path: "{{ matrix_static_files_base_path }}", when: true}
17+
when: "item.when | bool"
18+
19+
- name: Ensure matrix-static-files webserver paths exist
20+
ansible.builtin.file:
21+
path: "{{ item.path }}"
22+
state: directory
23+
mode: 0750
24+
owner: "{{ matrix_container_user_host_uid }}"
25+
group: "{{ matrix_container_user_host_gid }}"
26+
with_items:
1727
- {path: "{{ matrix_static_files_config_path }}", when: true}
1828
- {path: "{{ matrix_static_files_public_path }}", when: true}
1929
- {path: "{{ matrix_static_files_public_well_known_path }}", when: true}

roles/custom/matrix-synapse/defaults/main.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ matrix_synapse_version: v1.127.1
2121
matrix_synapse_username: ''
2222
matrix_synapse_uid: ''
2323
matrix_synapse_gid: ''
24+
matrix_synapse_host_filesystem_uid: ''
25+
matrix_synapse_host_filesystem_gid: ''
26+
matrix_synapse_docker_userns_enabled: false
27+
matrix_synapse_docker_userns_offset: 0
2428

2529
matrix_synapse_container_image_self_build: false
2630
matrix_synapse_container_image_self_build_repo: "https://github.com/{{ matrix_synapse_github_org_and_repo }}.git"
@@ -133,6 +137,9 @@ matrix_synapse_ext_s3_storage_provider_base_path: "{{ matrix_synapse_base_path }
133137
matrix_synapse_ext_s3_storage_provider_bin_path: "{{ matrix_synapse_ext_s3_storage_provider_base_path }}/bin"
134138
matrix_synapse_ext_s3_storage_provider_data_path: "{{ matrix_synapse_ext_s3_storage_provider_base_path }}/data"
135139

140+
matrix_synapse_passwd_file_path: ''
141+
matrix_synapse_group_file_path: ''
142+
136143
matrix_synapse_container_client_api_port: 8008
137144

138145
matrix_synapse_container_federation_api_tls_port: 8448

roles/custom/matrix-synapse/tasks/ext/encryption-disabler/setup_install.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
dest: "{{ matrix_synapse_ext_path }}/matrix_e2ee_filter.py"
1212
force: true
1313
mode: 0440
14-
owner: "{{ matrix_synapse_uid }}"
15-
group: "{{ matrix_synapse_gid }}"
14+
owner: "{{ matrix_synapse_host_filesystem_uid }}"
15+
group: "{{ matrix_synapse_host_filesystem_gid }}"
1616
register: result
1717
retries: "{{ devture_playbook_help_geturl_retries_count }}"
1818
delay: "{{ devture_playbook_help_geturl_retries_delay }}"

roles/custom/matrix-synapse/tasks/ext/mjolnir-antispam/setup_install.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@
2020
become: true
2121
become_user: "{{ matrix_synapse_username }}"
2222

23+
- name: Ensure directories and files have the right permissions
24+
ansible.builtin.file:
25+
path: "{{ matrix_synapse_ext_path }}/mjolnir"
26+
state: directory
27+
owner: "{{ matrix_synapse_host_filesystem_uid }}"
28+
group: "{{ matrix_synapse_host_filesystem_gid }}"
29+
recurse: true
30+
2331
- ansible.builtin.set_fact:
2432
matrix_synapse_modules: >
2533
{{

roles/custom/matrix-synapse/tasks/ext/rest-auth/setup_install.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
dest: "{{ matrix_synapse_ext_path }}/rest_auth_provider.py"
1919
force: true
2020
mode: 0440
21-
owner: "{{ matrix_synapse_uid }}"
22-
group: "{{ matrix_synapse_gid }}"
21+
owner: "{{ matrix_synapse_host_filesystem_uid }}"
22+
group: "{{ matrix_synapse_host_filesystem_gid }}"
2323
register: result
2424
retries: "{{ devture_playbook_help_geturl_retries_count }}"
2525
delay: "{{ devture_playbook_help_geturl_retries_delay }}"

0 commit comments

Comments
 (0)