| @@ -69,6 +69,14 @@ matrix_synapse_container_federation_api_tls_port: 8448 | |||||
| matrix_synapse_container_federation_api_plain_port: 8048 | matrix_synapse_container_federation_api_plain_port: 8048 | ||||
| # The base container network. It will be auto-created by this role if it doesn't exist already. | |||||
| matrix_synapse_container_network: "{{ matrix_docker_network }}" | |||||
| # A list of additional container networks that the container would be connected to. | |||||
| # The role does not create these networks, so make sure they already exist. | |||||
| # Use this to expose this container to another reverse proxy, which runs in a different container network. | |||||
| matrix_synapse_container_additional_networks: [] | |||||
| # Controls whether the matrix-synapse container exposes the Client/Server API port (tcp/{{ matrix_synapse_container_client_api_port }} in the container). | # Controls whether the matrix-synapse container exposes the Client/Server API port (tcp/{{ matrix_synapse_container_client_api_port }} in the container). | ||||
| # | # | ||||
| # Takes an "<ip>:<port>" or "<port>" value (e.g. "127.0.0.1:8008"), or empty string to not expose. | # Takes an "<ip>:<port>" or "<port>" value (e.g. "127.0.0.1:8008"), or empty string to not expose. | ||||
| @@ -661,7 +669,7 @@ matrix_synapse_redis_password: "" | |||||
| # | # | ||||
| # If Redis is available, we prefer to use that, instead of talking over Synapse's custom replication protocol. | # If Redis is available, we prefer to use that, instead of talking over Synapse's custom replication protocol. | ||||
| # | # | ||||
| # matrix_synapse_replication_listener_enabled: "{{ matrix_synapse_workers_enabled and not matrix_redis_enabled }}" | |||||
| # matrix_synapse_replication_listener_enabled: "{{ matrix_synapse_workers_enabled and not redis_enabled }}" | |||||
| # We force-enable this listener for now until we debug why communication via Redis fails. | # We force-enable this listener for now until we debug why communication via Redis fails. | ||||
| matrix_synapse_replication_listener_enabled: true | matrix_synapse_replication_listener_enabled: true | ||||
| @@ -122,6 +122,11 @@ | |||||
| dest: "{{ matrix_synapse_config_dir_path }}/{{ matrix_server_fqn_matrix }}.log.config" | dest: "{{ matrix_synapse_config_dir_path }}/{{ matrix_server_fqn_matrix }}.log.config" | ||||
| mode: 0644 | mode: 0644 | ||||
| - name: Ensure Synapse container network is created | |||||
| community.general.docker_network: | |||||
| name: "{{ matrix_synapse_container_network }}" | |||||
| driver: bridge | |||||
| - name: Ensure matrix-synapse.service installed | - name: Ensure matrix-synapse.service installed | ||||
| ansible.builtin.template: | ansible.builtin.template: | ||||
| src: "{{ role_path }}/templates/synapse/systemd/matrix-synapse.service.j2" | src: "{{ role_path }}/templates/synapse/systemd/matrix-synapse.service.j2" | ||||
| @@ -14,7 +14,9 @@ ExecStartPre=-{{ devture_systemd_docker_base_host_command_sh }} -c '{{ devture_s | |||||
| # Intentional delay, so that the homeserver can manage to start. | # Intentional delay, so that the homeserver can manage to start. | ||||
| ExecStartPre={{ matrix_host_command_sleep }} 5 | ExecStartPre={{ matrix_host_command_sleep }} 5 | ||||
| ExecStart={{ devture_systemd_docker_base_host_command_docker }} run --rm --name {{ matrix_synapse_worker_container_name }} \ | |||||
| ExecStartPre={{ devture_systemd_docker_base_host_command_docker }} create \ | |||||
| --rm \ | |||||
| --name={{ matrix_synapse_worker_container_name }} \ | |||||
| --log-driver=none \ | --log-driver=none \ | ||||
| --user={{ matrix_user_uid }}:{{ matrix_user_gid }} \ | --user={{ matrix_user_uid }}:{{ matrix_user_gid }} \ | ||||
| --cap-drop=ALL \ | --cap-drop=ALL \ | ||||
| @@ -45,6 +47,11 @@ ExecStart={{ devture_systemd_docker_base_host_command_docker }} run --rm --name | |||||
| {{ matrix_synapse_docker_image_final }} \ | {{ matrix_synapse_docker_image_final }} \ | ||||
| run -m synapse.app.{{ matrix_synapse_worker_details.app }} -c /data/homeserver.yaml -c /data/{{ matrix_synapse_worker_config_file_name }} | run -m synapse.app.{{ matrix_synapse_worker_details.app }} -c /data/homeserver.yaml -c /data/{{ matrix_synapse_worker_config_file_name }} | ||||
| {% for network in matrix_synapse_container_additional_networks %} | |||||
| ExecStartPre={{ devture_systemd_docker_base_host_command_docker }} network connect {{ network }} {{ matrix_synapse_worker_container_name }} | |||||
| {% endfor %} | |||||
| ExecStart={{ devture_systemd_docker_base_host_command_docker }} start --attach {{ matrix_synapse_worker_container_name }} | |||||
| ExecStop=-{{ devture_systemd_docker_base_host_command_sh }} -c '{{ devture_systemd_docker_base_host_command_docker }} kill {{ matrix_synapse_worker_container_name }} 2>/dev/null || true' | ExecStop=-{{ devture_systemd_docker_base_host_command_sh }} -c '{{ devture_systemd_docker_base_host_command_docker }} kill {{ matrix_synapse_worker_container_name }} 2>/dev/null || true' | ||||
| ExecStop=-{{ devture_systemd_docker_base_host_command_sh }} -c '{{ devture_systemd_docker_base_host_command_docker }} rm {{ matrix_synapse_worker_container_name }} 2>/dev/null || true' | ExecStop=-{{ devture_systemd_docker_base_host_command_sh }} -c '{{ devture_systemd_docker_base_host_command_docker }} rm {{ matrix_synapse_worker_container_name }} 2>/dev/null || true' | ||||
| @@ -30,7 +30,9 @@ ExecStartPre=-{{ devture_systemd_docker_base_host_command_sh }} -c '{{ devture_s | |||||
| ExecStartPre={{ matrix_host_command_sleep }} 3 | ExecStartPre={{ matrix_host_command_sleep }} 3 | ||||
| {% endif %} | {% endif %} | ||||
| ExecStart={{ devture_systemd_docker_base_host_command_docker }} run --rm --name matrix-synapse \ | |||||
| ExecStartPre={{ devture_systemd_docker_base_host_command_docker }} create \ | |||||
| --rm \ | |||||
| --name=matrix-synapse \ | |||||
| --log-driver=none \ | --log-driver=none \ | ||||
| --user={{ matrix_user_uid }}:{{ matrix_user_gid }} \ | --user={{ matrix_user_uid }}:{{ matrix_user_gid }} \ | ||||
| --cap-drop=ALL \ | --cap-drop=ALL \ | ||||
| @@ -63,8 +65,15 @@ ExecStart={{ devture_systemd_docker_base_host_command_docker }} run --rm --name | |||||
| {{ matrix_synapse_docker_image_final }} \ | {{ matrix_synapse_docker_image_final }} \ | ||||
| run -m synapse.app.homeserver -c /data/homeserver.yaml | run -m synapse.app.homeserver -c /data/homeserver.yaml | ||||
| {% for network in matrix_synapse_container_additional_networks %} | |||||
| ExecStartPre={{ devture_systemd_docker_base_host_command_docker }} network connect {{ network }} matrix-synapse | |||||
| {% endfor %} | |||||
| ExecStart={{ devture_systemd_docker_base_host_command_docker }} start --attach matrix-synapse | |||||
| ExecStop=-{{ devture_systemd_docker_base_host_command_sh }} -c '{{ devture_systemd_docker_base_host_command_docker }} kill matrix-synapse 2>/dev/null || true' | ExecStop=-{{ devture_systemd_docker_base_host_command_sh }} -c '{{ devture_systemd_docker_base_host_command_docker }} kill matrix-synapse 2>/dev/null || true' | ||||
| ExecStop=-{{ devture_systemd_docker_base_host_command_sh }} -c '{{ devture_systemd_docker_base_host_command_docker }} rm matrix-synapse 2>/dev/null || true' | ExecStop=-{{ devture_systemd_docker_base_host_command_sh }} -c '{{ devture_systemd_docker_base_host_command_docker }} rm matrix-synapse 2>/dev/null || true' | ||||
| ExecReload={{ devture_systemd_docker_base_host_command_docker }} exec matrix-synapse /bin/sh -c 'kill -HUP 1' | ExecReload={{ devture_systemd_docker_base_host_command_docker }} exec matrix-synapse /bin/sh -c 'kill -HUP 1' | ||||
| Restart=always | Restart=always | ||||
| RestartSec=30 | RestartSec=30 | ||||