Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Synapse workers #456

Merged
merged 88 commits into from
Feb 19, 2021
Merged
Show file tree
Hide file tree
Changes from 47 commits
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
353bc7c
Add initial support for synapse workers
eMPee584 Apr 10, 2020
a14b9c0
Add to synapse nginx template conditional URL rewrites for workers
eMPee584 Apr 11, 2020
cf452fd
Fix corner-cases found through testing (aka ansible is nuts)
eMPee584 Apr 19, 2020
66a4073
Publish synapse worker ports, need to be accessible to nginx
eMPee584 Apr 19, 2020
e4763c2
nginx config: route traffic to workers on matrix-synapse
eMPee584 Apr 19, 2020
5f63d28
Move synapse worker ports up 10k
eMPee584 Apr 19, 2020
765c046
add missing ; to matrix-synapse.conf.j2
JohannesKleine Apr 19, 2020
46984a4
Nginx conf: more testing less b0rk
eMPee584 Apr 19, 2020
567d031
Merge branch 'synapse-workers' into feature/add-worker-support
maxklenk Aug 27, 2020
59d1fb7
only apply worker redirects if workers are enabled
maxklenk Aug 27, 2020
53ccc78
remove duplicated key
maxklenk Aug 27, 2020
06bc430
refactor to use new workers and routes they serve
maxklenk Aug 28, 2020
a25a429
add redis support
maxklenk Sep 10, 2020
9a3d84b
Merge branch 'master' into feature/add-worker-support
maxklenk Sep 10, 2020
4fdfc0a
add missing ratelimiting options required for load testing
maxklenk Sep 11, 2020
8800253
fix redis config if no password is set
maxklenk Sep 11, 2020
1e68d8b
allow to pass arguments to the postgres process
maxklenk Sep 11, 2020
132daba
fix worker routes
maxklenk Sep 18, 2020
fc2edcb
fix media routing
maxklenk Sep 18, 2020
93a8ea7
Merge remote-tracking branch 'master' into feature/add-worker-support
eMPee584 Oct 11, 2020
40024e9
Prevent workers failing if their config doesn't exist
eMPee584 Sep 29, 2020
e9241f5
Improve synapse-workers systemd service template
eMPee584 Oct 11, 2020
36e9be6
matrix_synapse_workers_{avail,enabled}_list: sort non-generic workers
eMPee584 Oct 11, 2020
d2e61af
Add worker_name to synapse worker config template
eMPee584 Sep 9, 2020
501efee
synapse workers: supply systemd with actual worker PIDs (requires jq)
eMPee584 Oct 22, 2020
a4125d5
synapse workers: polishing, cleansing and installation of jq dependency
eMPee584 Oct 23, 2020
87bd64c
Merge remote-tracking branch 'origin/master' into synapse-workers
eMPee584 Oct 23, 2020
2d1b9f2
synapse workers: reworkings + get endpoints from upstream docs via awk
eMPee584 Oct 28, 2020
e078e29
synapse workers: fix self name in workers-doc-to-yaml.awk script
eMPee584 Oct 28, 2020
cce90b1
synapse workers: fix undefined variable cases when removing workers
eMPee584 Oct 28, 2020
e5072c2
synapse workers/nginx: handle media_repository worker endpoints on fe…
eMPee584 Nov 10, 2020
1e97131
synapse workers: handle auth fallback endpoint on main process only
eMPee584 Nov 10, 2020
b05d298
synapse workers nginx rule: add client_max_body_size on media endpoints
eMPee584 Nov 10, 2020
dd402be
synapse workers: add rudimentary documentation on worker support
eMPee584 Nov 10, 2020
f3d2797
synapse workers: make awk script invocation handle paths with spaces
eMPee584 Nov 10, 2020
5598a89
synapse workers doc: link to relevant synapse issue list search
eMPee584 Nov 10, 2020
4678c5d
Merge remote-tracking branch 'origin/master' into synapse-workers
eMPee584 Nov 11, 2020
b73ac96
Merge remote-tracking branch 'origin/master' into synapse-workers
eMPee584 Dec 1, 2020
e314613
Add files created by workers-doc-to-yaml.awk to .gitignore
eMPee584 Dec 1, 2020
851c25c
matrix-synapse nginx template: fix invalid jinja comment syntax
eMPee584 Dec 1, 2020
d5932ca
synapse role workers setup: execute the endpoint extraction locally
eMPee584 Dec 1, 2020
414b812
synapse role workers setup: make configs clean action remote compatible
eMPee584 Dec 1, 2020
af08f18
synapse workers default config: disable user_dir worker for now
eMPee584 Dec 1, 2020
f201bca
synapse workers: define and expose METRICS port for each worker
eMPee584 Dec 1, 2020
e892ac4
synapse workers: untangle config template and specify bind address
eMPee584 Dec 1, 2020
3156d96
synapse workers-doc-to-yaml.awk: escape slash for non-gnu awk versions
eMPee584 Dec 1, 2020
b6b95fe
synapse workers-doc-to-yaml script: compatibility++ with non-gnu awk
eMPee584 Dec 2, 2020
cd81005
Merge remote-tracking branch 'origin/master' into synapse-workers
eMPee584 Jan 8, 2021
f2c7d79
Drop probably incorrect comment from synapse homeserver.yaml.j2
eMPee584 Jan 23, 2021
c8f051a
Track workers endpoint list in repo instead of regenerating on user side
eMPee584 Jan 23, 2021
183adec
Merge remote-tracking branch 'origin/master' into synapse-workers
eMPee584 Jan 23, 2021
edc21f1
Restrict publishing worker (metrics) ports to localhost
eMPee584 Jan 24, 2021
92ee3d7
Fix matrix-remove-all for when Synapse workers are enabled
spantaleev Jan 24, 2021
cc5cf0d
Load roles/matrix-synapse/vars/workers.yml earlier to not break --tag…
spantaleev Jan 24, 2021
5ca6821
Do not handle /_matrix/federation on client-server port, nor /_matrix…
spantaleev Jan 24, 2021
f66a6b0
Be more specific with the Redis version being used
spantaleev Jan 24, 2021
63301b0
Improvements around Synapse worker/metrics ports exposure
spantaleev Jan 25, 2021
c05d3d0
Disable systemd services while stopping them
spantaleev Jan 25, 2021
4d62a75
Get matrix-corporal to play nicely with a Synapse worker setup
spantaleev Jan 25, 2021
da50fb2
Whitelist /_matrix/key requests for going to generic workers on the f…
spantaleev Jan 25, 2021
7079670
Run Synapse workers in their own containers
spantaleev Jan 25, 2021
01747c8
Prevent Synapse warning about enabling metric listeners with enable_m…
spantaleev Jan 25, 2021
1462409
Fix worker listening addresses
spantaleev Jan 25, 2021
66cdc7b
Clean up worker.yaml generation a bit and make it more flexible
spantaleev Jan 25, 2021
d3ecc6f
Fix bridges failing to upload media when Synapse workers are enabled
spantaleev Jan 25, 2021
70dcdd4
Simplify matrix-remove-all
spantaleev Jan 25, 2021
778b668
Merge branch 'master' into synapse-workers
spantaleev Jan 25, 2021
a535226
Stop/disable unnecessary worker services before deleting them
spantaleev Jan 25, 2021
a9af368
Merge branch 'master' into synapse-workers
spantaleev Jan 27, 2021
d98a1ce
Merge branch 'master' into synapse-workers
spantaleev Jan 27, 2021
a31c960
Merge branch 'master' into synapse-workers
spantaleev Jan 27, 2021
a49dab7
Merge branch 'master' into synapse-workers
spantaleev Jan 27, 2021
39c2d72
Merge branch 'master' into synapse-workers
spantaleev Jan 27, 2021
1cd2a21
Merge branch 'master' into synapse-workers
spantaleev Jan 27, 2021
e7f3f7c
Enable /devices endpoint for generic workers
spantaleev Jan 27, 2021
5cfeae8
Merge branch 'master' into synapse-workers
spantaleev Feb 14, 2021
453a4ec
Relocate tasks related to Synapse workers
spantaleev Feb 15, 2021
43059bb
Fix metrics listeners for Synapse workers
spantaleev Feb 15, 2021
85a05f3
Allow Synapse worker list to be generated dynamically
spantaleev Feb 15, 2021
61e427d
Do not let people enable more than 1 federation_sender worker
spantaleev Feb 15, 2021
daae74b
Merge branch 'master' into synapse-workers
spantaleev Feb 16, 2021
d33483b
Document that Synapse pusher worker instances are shardable
spantaleev Feb 16, 2021
d6c4d41
Define instanceId property on workers
spantaleev Feb 18, 2021
1789620
Merge branch 'master' into synapse-workers
spantaleev Feb 18, 2021
2f732e4
Update Synapse worker endpoints
spantaleev Feb 19, 2021
eaea215
Allow Synapse workers to be used with an external nginx webserver
spantaleev Feb 19, 2021
9dc87bb
Add Synapse worker presets for easier configuration
spantaleev Feb 19, 2021
b754c27
Announce Synapse workers support
spantaleev Feb 19, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@
!/inventory/host_vars/.gitkeep
!/inventory/scripts
/roles/*/files/scratchpad
/roles/matrix-synapse/files/workers.upstream-documentation.md
/roles/matrix-synapse/vars/workers.yml
.DS_Store
.python-version
17 changes: 17 additions & 0 deletions docs/configuring-playbook-synapse.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,23 @@ Alternatively, **if there is no pre-defined variable** for a Synapse setting you
- or, if extending the configuration is still not powerful enough for your needs, you can **override the configuration completely** using `matrix_synapse_configuration` (or `matrix_synapse_configuration_yaml`). You can find information about this in [`roles/matrix-synapse/defaults/main.yml`](../roles/matrix-synapse/defaults/main.yml).


## Load balancing with workers
To have synapse gracefully handle thousands of users, worker support should be enabled. It factors out some homeserver tasks and spreads the load of incoming client and server-to-server traffic between multiple processes. More information can be found at https://github.com/matrix-org/synapse/blob/master/docs/workers.md (which, coincidentally, also is the file which an awk script extracts the endpoint URLs from when running with tag `setup-synapse`).

To enable synapse worker support, set

```yaml
matrix_synapse_workers_enabled: true
```

in your `inventory/host_vars/matrix.DOMAIN/vars.yml` file.
There, you can also override the default `matrix_synapse_workers_enabled_list` from [`roles/matrix-synapse/defaults/main.yml`](../roles/matrix-synapse/defaults/main.yml).

If you are not using the inbuilt nginx proxy container but an instance managed by yourself, you are currently on your own as the template needs yet to be adapted to better support this use case.

In case any problems occur, make sure to have a look at the [list of synapse issues about workers](https://github.com/matrix-org/synapse/issues?q=workers+in%3Atitle) and your `journalctl --unit 'matrix-*'`.


## Synapse Admin

Certain Synapse administration tasks (managing users and rooms, etc.) can be performed via a web user-interace, if you install [Synapse Admin](configuring-playbook-synapse-admin.md).
Expand Down
30 changes: 30 additions & 0 deletions group_vars/matrix_servers
Original file line number Diff line number Diff line change
Expand Up @@ -830,6 +830,15 @@ matrix_nginx_proxy_proxy_matrix_user_directory_search_addr_sans_container: "{{ m

matrix_nginx_proxy_self_check_validate_certificates: "{{ false if matrix_ssl_retrieval_method == 'self-signed' else true }}"

matrix_nginx_proxy_synapse_presence_disabled: "{{ not matrix_synapse_use_presence }}"

matrix_nginx_proxy_synapse_workers_enabled: "{{ matrix_synapse_workers_enabled }}"
matrix_nginx_proxy_synapse_workers_list: "{{ matrix_synapse_workers_enabled_list }}"
matrix_nginx_proxy_synapse_generic_worker_locations: "{{ matrix_synapse_workers_generic_worker_endpoints|default([]) }}"
matrix_nginx_proxy_synapse_media_repository_locations: "{{ matrix_synapse_workers_media_repository_endpoints|default([]) }}"
matrix_nginx_proxy_synapse_user_dir_locations: "{{ matrix_synapse_workers_user_dir_endpoints|default([]) }}"
matrix_nginx_proxy_synapse_frontend_proxy_locations: "{{ matrix_synapse_workers_frontend_proxy_endpoints|default([]) }}"

matrix_nginx_proxy_systemd_wanted_services_list: |
{{
(['matrix-synapse.service'])
Expand Down Expand Up @@ -896,6 +905,22 @@ matrix_postgres_db_name: "homeserver"



######################################################################
#
# matrix-redis
#
######################################################################

matrix_redis_enabled: "{{ matrix_synapse_workers_enabled }}"

######################################################################
#
# /matrix-redis
#
######################################################################



######################################################################
#
# matrix-client-element
Expand Down Expand Up @@ -1035,6 +1060,11 @@ matrix_synapse_systemd_wanted_services_list: |
(['matrix-mailer.service'] if matrix_mailer_enabled else [])
}}

# Synapse workers (used for parallel load-scaling) need Redis for IPC.
matrix_synapse_redis_enabled: "{{ matrix_redis_enabled }}"
matrix_synapse_redis_host: "{{ 'matrix-redis' if matrix_redis_enabled else '' }}"
matrix_synapse_redis_password: "{{ matrix_redis_connection_password if matrix_redis_enabled else '' }}"

######################################################################
#
# /matrix-synapse
Expand Down
9 changes: 9 additions & 0 deletions roles/matrix-nginx-proxy/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -283,3 +283,12 @@ matrix_ssl_pre_obtaining_required_service_start_wait_time_seconds: 60
# nginx status page configurations.
matrix_nginx_proxy_proxy_matrix_nginx_status_enabled: false
matrix_nginx_proxy_proxy_matrix_nginx_status_allowed_addresses: ['{{ ansible_default_ipv4.address }}']


# synapse worker activation and endpoint mappings
matrix_nginx_proxy_synapse_workers_enabled: false
matrix_nginx_proxy_synapse_workers_list: []
matrix_nginx_proxy_synapse_generic_worker_locations: []
matrix_nginx_proxy_synapse_media_repository_locations: []
matrix_nginx_proxy_synapse_user_dir_locations: []
matrix_nginx_proxy_synapse_frontend_proxy_locations: []
139 changes: 139 additions & 0 deletions roles/matrix-nginx-proxy/templates/nginx/conf.d/matrix-synapse.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@
{% endif %}

{% if matrix_nginx_proxy_proxy_matrix_user_directory_search_enabled %}
# NOTE: This redirects user lookup requests to the identity server instead of
# synapse, so user_dir_workers endpoints listed further down in this file will
# not be reached and workers of this kind should be disabled for consistency.
location ^~ /_matrix/client/r0/user_directory/search {
{% if matrix_nginx_proxy_enabled %}
{# Use the embedded DNS resolver in Docker containers to discover the service #}
Expand Down Expand Up @@ -101,6 +104,70 @@
}
{% endif %}

{% if matrix_nginx_proxy_synapse_workers_enabled %}
{# Workers redirects BEGIN #}

{% if generic_workers %}
# https://github.com/matrix-org/synapse/blob/master/docs/workers.md#synapseappgeneric_worker
{% for location in matrix_nginx_proxy_synapse_generic_worker_locations %}
location ~ {{ location }} {
proxy_pass http://generic_worker_upstream$request_uri;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $remote_addr;
}
{% endfor %}
# FIXME: add GET ^/_matrix/federation/v1/groups/
{% endif %}

{% if media_repository_workers %}
# https://github.com/matrix-org/synapse/blob/master/docs/workers.md#synapseappmedia_repository
{% for location in matrix_nginx_proxy_synapse_media_repository_locations %}
location ~ {{ location }} {
proxy_pass http://media_repository_upstream$request_uri;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $remote_addr;

client_body_buffer_size 25M;
client_max_body_size {{ matrix_nginx_proxy_proxy_matrix_client_api_client_max_body_size_mb }}M;
proxy_max_temp_file_size 0;
}
{% endfor %}
{% endif %}

{% if user_dir_workers %}
# FIXME: obsolete if matrix_nginx_proxy_proxy_matrix_user_directory_search_enabled is set
# https://github.com/matrix-org/synapse/blob/master/docs/workers.md#synapseappuser_dir
{% for location in matrix_nginx_proxy_synapse_user_dir_locations %}
location ~ {{ location }} {
proxy_pass http://user_dir_upstream$request_uri;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $remote_addr;
}
{% endfor %}
{% endif %}

{% if frontend_proxy_workers %}
# https://github.com/matrix-org/synapse/blob/master/docs/workers.md#synapseappfrontend_proxy
{% for location in matrix_nginx_proxy_synapse_frontend_proxy_locations %}
location ~ {{ location }} {
proxy_pass http://frontend_proxy_upstream$request_uri;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $remote_addr;
}
{% endfor %}
{% if matrix_nginx_proxy_synapse_presence_disabled %}
# FIXME: keep in sync with synapse workers documentation manually
location ~ ^/_matrix/client/(api/v1|r0|unstable)/presence/[^/]+/status {
proxy_pass http://frontend_proxy_upstream$request_uri;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $remote_addr;
}
{% endif %}
{% endif %}
{# Workers redirects END #}
{% endif %}


{% for configuration_block in matrix_nginx_proxy_proxy_matrix_additional_server_configuration_blocks %}
{{- configuration_block }}
{% endfor %}
Expand Down Expand Up @@ -159,6 +226,50 @@
}
{% endmacro %}

{% set generic_workers = matrix_nginx_proxy_synapse_workers_list|selectattr('type', 'equalto', 'generic_worker')|list %}
{% set media_repository_workers = matrix_nginx_proxy_synapse_workers_list|selectattr('type', 'equalto', 'media_repository')|list %}
{% set user_dir_workers = matrix_nginx_proxy_synapse_workers_list|selectattr('type', 'equalto', 'user_dir')|list %}
{% set frontend_proxy_workers = matrix_nginx_proxy_synapse_workers_list|selectattr('type', 'equalto', 'frontend_proxy')|list %}
{% if matrix_nginx_proxy_synapse_workers_enabled %}
# Round Robin "upstream" pools for workers

{% if generic_workers %}
upstream generic_worker_upstream {
# ensures that requests from the same client will always be passed
# to the same server (except when this server is unavailable)
ip_hash;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/matrix-org/synapse/blob/develop/docs/workers.md According to the official docs, it is recommended to balance the federation API by ip (as done here), but balancing the client API /sync (etc) by Authorization header (as the IP might change, but the session persists). If i see it correctly, there is no such "fancy" balancing done here (yet)?

Copy link
Contributor Author

@eMPee584 eMPee584 Dec 14, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. Which key for the http://nginx.org/en/docs/http/ngx_http_upstream_module.html#hash directive would you propose for that?
The average user might have two devices online with different IPs. Balancing by IP would get the traffic of both be handled by different workers, balancing by authorization would make them go to the same.
It might marginally improve the load because of less cache faults.. Than again, no idea how well the new redis IPC catches that.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hash $http_authorization should balance connections by the value of the Authorization header. For a single-user multi-device setups, there is little benefit, but if you have e.g. 10 users with each 2-3 sessions, each user w/ all their sessions would be bound to one backend, enabling fast /syncs and not stalling other users too much if someone does an /initialsync - this applies only to the /[initial]sync endpoints (and 2-3 others), the rest of the CS-API-endpoints can be balanced by source IP aswell.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How would you make all of the user's sessions land on the same worker? Doesn't each session gets its own access token and thus has its own unique Authorization header.

The best that should be possible with this is to have each session land the same worker, but not have all these sessions (for the same user) do that.

Unless there's something smart which could parse the macaroon out of the Authorization header, read the user id out of it and then balance based on that value.

I see that workers.md says the same:

For /sync and /initialSync requests it will be more efficient if all requests from a particular user are routed to a single instance. Extracting a user ID from the access token or Authorization header is currently left as an exercise for the reader.

Well, how does one solve that exercise (in nginx), I don't know.

Copy link

@bjeanes bjeanes Jan 12, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/bungle/awesome-resty#authentication-and-authorization has a macroon lib, so in principle it might be possible using OpenResty (nginx distribution with lots of lua modules)

E but I think keeping it simple for now is still such a huge improvement over no worker support. Making it more fancy down the line can always be done in a diff PR


{% for worker in generic_workers %}
server "matrix-synapse:{{ worker.port }}";
{% endfor %}
}
{% endif %}

{% if frontend_proxy_workers %}
upstream frontend_proxy_upstream {
{% for worker in frontend_proxy_workers %}
server "matrix-synapse:{{ worker.port }}";
{% endfor %}
}
{% endif %}

{% if media_repository_workers %}
upstream media_repository_upstream {
{% for worker in media_repository_workers %}
server "matrix-synapse:{{ worker.port }}";
{% endfor %}
}
{% endif %}

{% if user_dir_workers %}
upstream user_dir_upstream {
{% for worker in user_dir_workers %}
server "matrix-synapse:{{ worker.port }}";
{% endfor %}
}
{% endif %}
{% endif %}

server {
listen {{ 8080 if matrix_nginx_proxy_enabled else 80 }};
server_name {{ matrix_nginx_proxy_proxy_matrix_hostname }};
Expand Down Expand Up @@ -240,6 +351,34 @@ server {
ssl_ciphers "EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH";
{% endif %}

{% if matrix_nginx_proxy_synapse_workers_enabled %}
{% if generic_workers %}
# https://github.com/matrix-org/synapse/blob/master/docs/workers.md#synapseappgeneric_worker
{% for location in matrix_nginx_proxy_synapse_generic_worker_locations %}
location ~ {{ location }} {
proxy_pass http://generic_worker_upstream$request_uri;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $remote_addr;
}
{% endfor %}
# FIXME: add GET ^/_matrix/federation/v1/groups/
{% endif %}
{% if media_repository_workers %}
# https://github.com/matrix-org/synapse/blob/master/docs/workers.md#synapseappmedia_repository
{% for location in matrix_nginx_proxy_synapse_media_repository_locations %}
location ~ {{ location }} {
proxy_pass http://media_repository_upstream$request_uri;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $remote_addr;

client_body_buffer_size 25M;
client_max_body_size {{ matrix_nginx_proxy_proxy_matrix_federation_api_client_max_body_size_mb }}M;
proxy_max_temp_file_size 0;
}
{% endfor %}
{% endif %}
{% endif %}

location / {
{% if matrix_nginx_proxy_enabled %}
{# Use the embedded DNS resolver in Docker containers to discover the service #}
Expand Down
4 changes: 4 additions & 0 deletions roles/matrix-postgres/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ matrix_postgres_docker_image_force_pull: "{{ matrix_postgres_docker_image_to_use
# A list of extra arguments to pass to the container
matrix_postgres_container_extra_arguments: []

# A list of extra arguments to pass to the postgres process
# e.g. "-c 'max_connections=200'"
matrix_postgres_process_extra_arguments: []

# Controls whether the matrix-postgres container exposes a port (tcp/5432 in the
# container) that can be used to access the database from outside the container (e.g. with psql)
#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ ExecStart={{ matrix_host_command_docker }} run --rm --name matrix-postgres \
{% for arg in matrix_postgres_container_extra_arguments %}
{{ arg }} \
{% endfor %}
{{ matrix_postgres_docker_image_to_use }}
{{ matrix_postgres_docker_image_to_use }} \
postgres \
{% for arg in matrix_postgres_process_extra_arguments %}
{{ arg }} \
{% endfor %}

ExecStop=-{{ matrix_host_command_docker }} stop matrix-postgres
ExecStop=-{{ matrix_host_command_docker }} rm matrix-postgres
Expand Down
22 changes: 22 additions & 0 deletions roles/matrix-redis/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
matrix_redis_enabled: true
eMPee584 marked this conversation as resolved.
Show resolved Hide resolved

matrix_redis_connection_password: ""

matrix_redis_base_path: "{{ matrix_base_data_path }}/redis"
matrix_redis_data_path: "{{ matrix_redis_base_path }}/data"

matrix_redis_docker_image_v5: "redis:5.0-alpine"
matrix_redis_docker_image_v6: "redis:6.0-alpine"
matrix_redis_docker_image_latest: "{{ matrix_redis_docker_image_v6 }}"
matrix_redis_docker_image_to_use: '{{ matrix_redis_docker_image_latest }}'

matrix_redis_docker_image_force_pull: "{{ matrix_redis_docker_image_to_use.endswith(':latest') }}"

# A list of extra arguments to pass to the container
matrix_redis_container_extra_arguments: []

# Controls whether the matrix-redis container exposes a port (tcp/6379 in the container)
# that can be used to access redis from outside the container
#
# Takes an "<ip>:<port>" or "<port>" value (e.g. "127.0.0.1:6379"), or empty string to not expose.
matrix_redis_container_redis_bind_port: ""
3 changes: 3 additions & 0 deletions roles/matrix-redis/tasks/init.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- set_fact:
matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-redis'] }}"
when: matrix_redis_enabled|bool
9 changes: 9 additions & 0 deletions roles/matrix-redis/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
- import_tasks: "{{ role_path }}/tasks/init.yml"
tags:
- always

- import_tasks: "{{ role_path }}/tasks/setup_redis.yml"
when: run_setup|bool
tags:
- setup-all
- setup-redis
Loading