Compare commits
18 Commits
361e7d7e6b
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bdc9e46534 | ||
|
|
e92410cac2 | ||
|
|
af224d8312 | ||
|
|
dc1e49c6e1 | ||
|
|
1bfb412cf8 | ||
|
|
a26da1869b | ||
|
|
89af77a2d1 | ||
|
|
ea8e0d5b71 | ||
|
|
323ec0152f | ||
|
|
979a6814b0 | ||
|
|
a4b65f5b50 | ||
|
|
d1bbd974ab | ||
|
|
0033ffc405 | ||
|
|
46dc53580e | ||
|
|
2be85606c5 | ||
|
|
db29f26d7a | ||
|
|
e8696ea656 | ||
|
|
0f86bfbc02 |
@@ -3,8 +3,4 @@
|
|||||||
Roles for matrix services
|
Roles for matrix services
|
||||||
|
|
||||||
# To do
|
# To do
|
||||||
- Add argument spec validation
|
See [issues](https://git.uumas.fi/uumas/ansible-matrix/issues)
|
||||||
- Move ldap auth provider from password providers to collections
|
|
||||||
- Implement synchrotron balancing in nginx
|
|
||||||
- Make updates optional (use state: present instead of state: latest unless requested)
|
|
||||||
- Only restart extras being changed, not all
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
namespace: uumas
|
namespace: uumas
|
||||||
name: matrix
|
name: matrix
|
||||||
description: Matrix roles
|
description: Matrix roles
|
||||||
version: 0.0.1
|
version: 0.0.4
|
||||||
readme: README.md
|
readme: README.md
|
||||||
repository: https://git.uumas.fi/uumas/ansible-matrix
|
repository: https://git.uumas.fi/uumas/ansible-matrix
|
||||||
license_file: LICENSE
|
license_file: LICENSE
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
---
|
---
|
||||||
|
|
||||||
|
# Worker endpoints last updated on 2023-07-18
|
||||||
nginx_upstreams:
|
nginx_upstreams:
|
||||||
synapse_main:
|
synapse_main:
|
||||||
servers:
|
servers:
|
||||||
@@ -21,13 +22,15 @@ nginx_upstreams:
|
|||||||
additional_options:
|
additional_options:
|
||||||
- "client_max_body_size {{ matrix_max_upload_size_mb }}M"
|
- "client_max_body_size {{ matrix_max_upload_size_mb }}M"
|
||||||
|
|
||||||
synchrotron_balancer:
|
synapse_generic_sync:
|
||||||
servers: "{{ ['8183'] if synapse_workers.generic_sync is defined else '' }}"
|
servers: "{{ synapse_workers.generic_sync | default('') }}"
|
||||||
|
method: 'hash $mxid_localpart'
|
||||||
locations:
|
locations:
|
||||||
- name: '~ ^/_matrix/client/(api/v1|r0|v3)/events$'
|
- name: '~ ^/_matrix/client/(api/v1|r0|v3)/events$'
|
||||||
- name: "{{ '^/_matrix/client/(v2_alpha|r0|v3)/sync$' if 'generic_init_sync' not in synapse_workers | default('') else '' }}"
|
- name: "{{ '^/_matrix/client/(v2_alpha|r0|v3)/sync$' if 'generic_init_sync' not in synapse_workers | default('') else '' }}"
|
||||||
synchrotron_init:
|
synapse_generic_init_sync:
|
||||||
servers: "{{ ['8184'] if synapse_workers.generic_init_sync is defined else '' }}"
|
servers: "{{ synapse_workers.generic_init_sync | default('') }}"
|
||||||
|
method: 'hash $mxid_localpart'
|
||||||
locations:
|
locations:
|
||||||
- name: '~ ^/_matrix/client/(api/v1|r0|v3)/initialSync$'
|
- name: '~ ^/_matrix/client/(api/v1|r0|v3)/initialSync$'
|
||||||
- name: '~ ^/_matrix/client/(api/v1|r0|v3)/rooms/[^/]+/initialSync$'
|
- name: '~ ^/_matrix/client/(api/v1|r0|v3)/rooms/[^/]+/initialSync$'
|
||||||
@@ -41,7 +44,8 @@ nginx_upstreams:
|
|||||||
- name: '~ ^/_matrix/client/(api/v1|r0|v3|unstable)/rooms/.*/members$'
|
- name: '~ ^/_matrix/client/(api/v1|r0|v3|unstable)/rooms/.*/members$'
|
||||||
- name: '~ ^/_matrix/client/(api/v1|r0|v3|unstable)/rooms/.*/state$'
|
- name: '~ ^/_matrix/client/(api/v1|r0|v3|unstable)/rooms/.*/state$'
|
||||||
- name: '~ ^/_matrix/client/v1/rooms/.*/hierarchy$'
|
- name: '~ ^/_matrix/client/v1/rooms/.*/hierarchy$'
|
||||||
- name: '~ ^/_matrix/client/unstable/org.matrix.msc2716/rooms/.*/batch_send$'
|
- name: '~ ^/_matrix/client/(v1|unstable)/rooms/.*/relations/'
|
||||||
|
- name: '~ ^/_matrix/client/v1/rooms/.*/threads$'
|
||||||
- name: '~ ^/_matrix/client/unstable/im.nheko.summary/rooms/.*/summary$'
|
- name: '~ ^/_matrix/client/unstable/im.nheko.summary/rooms/.*/summary$'
|
||||||
- name: '~ ^/_matrix/client/(r0|v3|unstable)/account/3pid$'
|
- name: '~ ^/_matrix/client/(r0|v3|unstable)/account/3pid$'
|
||||||
- name: '~ ^/_matrix/client/(r0|v3|unstable)/account/whoami$'
|
- name: '~ ^/_matrix/client/(r0|v3|unstable)/account/whoami$'
|
||||||
@@ -50,7 +54,12 @@ nginx_upstreams:
|
|||||||
- name: '~ ^/_matrix/client/(api/v1|r0|v3|unstable)/voip/turnServer$'
|
- name: '~ ^/_matrix/client/(api/v1|r0|v3|unstable)/voip/turnServer$'
|
||||||
- name: '~ ^/_matrix/client/(api/v1|r0|v3|unstable)/rooms/.*/event/'
|
- name: '~ ^/_matrix/client/(api/v1|r0|v3|unstable)/rooms/.*/event/'
|
||||||
- name: '~ ^/_matrix/client/(api/v1|r0|v3|unstable)/joined_rooms$'
|
- name: '~ ^/_matrix/client/(api/v1|r0|v3|unstable)/joined_rooms$'
|
||||||
|
- name: '~ ^/_matrix/client/v1/rooms/.*/timestamp_to_event$'
|
||||||
|
- name: '~ ^/_matrix/client/(api/v1|r0|v3|unstable/.*)/rooms/.*/aliases'
|
||||||
- name: '~ ^/_matrix/client/(api/v1|r0|v3|unstable)/search$'
|
- name: '~ ^/_matrix/client/(api/v1|r0|v3|unstable)/search$'
|
||||||
|
- name: '~ ^/_matrix/client/(r0|v3|unstable)/user/.*/filter(/|$)'
|
||||||
|
- name: '~ ^/_matrix/client/(api/v1|r0|v3|unstable)/directory/room/.*$'
|
||||||
|
- name: '~ ^/_matrix/client/(r0|v3|unstable)/capabilities$'
|
||||||
|
|
||||||
- name: '~ ^/_matrix/client/(api/v1|r0|v3|unstable)/keys/query$'
|
- name: '~ ^/_matrix/client/(api/v1|r0|v3|unstable)/keys/query$'
|
||||||
additional_options:
|
additional_options:
|
||||||
@@ -58,12 +67,15 @@ nginx_upstreams:
|
|||||||
- name: '~ ^/_matrix/client/(api/v1|r0|v3|unstable)/keys/changes$'
|
- name: '~ ^/_matrix/client/(api/v1|r0|v3|unstable)/keys/changes$'
|
||||||
- name: '~ ^/_matrix/client/(r0|v3|unstable)/keys/claim$'
|
- name: '~ ^/_matrix/client/(r0|v3|unstable)/keys/claim$'
|
||||||
- name: '~ ^/_matrix/client/(r0|v3|unstable)/room_keys/'
|
- name: '~ ^/_matrix/client/(r0|v3|unstable)/room_keys/'
|
||||||
|
- name: '~ ^/_matrix/client/(r0|v3|unstable)/keys/upload/'
|
||||||
synapse_generic_login:
|
synapse_generic_login:
|
||||||
servers: "{{ synapse_workers.generic_login | default('') }}"
|
servers: "{{ synapse_workers.generic_login | default('') }}"
|
||||||
locations:
|
locations:
|
||||||
- name: '~ ^/_matrix/client/(api/v1|r0|unstable|v3)/login$'
|
- name: '~ ^/_matrix/client/(api/v1|r0|unstable|v3)/login$'
|
||||||
- name: '~ ^/_matrix/client/(r0|unstable|v3)/register$'
|
- name: '~ ^/_matrix/client/(r0|unstable|v3)/register$'
|
||||||
|
- name: '~ ^/_matrix/client/(r0|v3|unstable)/register/available$'
|
||||||
- name: '~ ^/_matrix/client/v1/register/m.login.registration_token/validity$'
|
- name: '~ ^/_matrix/client/v1/register/m.login.registration_token/validity$'
|
||||||
|
- name: '~ ^/_matrix/client/(r0|v3|unstable)/password_policy$'
|
||||||
# SSO
|
# SSO
|
||||||
- name: '~ ^/_matrix/client/(api/v1|r0|v3|unstable)/login/sso/redirect'
|
- name: '~ ^/_matrix/client/(api/v1|r0|v3|unstable)/login/sso/redirect'
|
||||||
- name: '~ ^/_synapse/client/pick_idp$'
|
- name: '~ ^/_synapse/client/pick_idp$'
|
||||||
@@ -94,6 +106,7 @@ nginx_upstreams:
|
|||||||
- name: '~ ^/_matrix/federation/(v1|v2)/send_leave/'
|
- name: '~ ^/_matrix/federation/(v1|v2)/send_leave/'
|
||||||
- name: '~ ^/_matrix/federation/(v1|v2)/invite/'
|
- name: '~ ^/_matrix/federation/(v1|v2)/invite/'
|
||||||
- name: '~ ^/_matrix/federation/v1/event_auth/'
|
- name: '~ ^/_matrix/federation/v1/event_auth/'
|
||||||
|
- name: '~ ^/_matrix/federation/v1/timestamp_to_event/'
|
||||||
- name: '~ ^/_matrix/federation/v1/exchange_third_party_invite/'
|
- name: '~ ^/_matrix/federation/v1/exchange_third_party_invite/'
|
||||||
- name: '~ ^/_matrix/federation/v1/user/devices/'
|
- name: '~ ^/_matrix/federation/v1/user/devices/'
|
||||||
- name: '~ ^/_matrix/key/v2/query'
|
- name: '~ ^/_matrix/key/v2/query'
|
||||||
@@ -116,6 +129,7 @@ nginx_upstreams:
|
|||||||
- name: '~ ^/_matrix/client/(api/v1|r0|v3|unstable)/join/'
|
- name: '~ ^/_matrix/client/(api/v1|r0|v3|unstable)/join/'
|
||||||
additional_options:
|
additional_options:
|
||||||
- 'proxy_read_timeout 1h'
|
- 'proxy_read_timeout 1h'
|
||||||
|
- name: '~ ^/_matrix/client/(api/v1|r0|v3|unstable)/knock/'
|
||||||
- name: '~ ^/_matrix/client/(api/v1|r0|v3|unstable)/profile/'
|
- name: '~ ^/_matrix/client/(api/v1|r0|v3|unstable)/profile/'
|
||||||
synapse_generic_pagination:
|
synapse_generic_pagination:
|
||||||
servers: "{{ synapse_workers.generic_pagination | default('') }}"
|
servers: "{{ synapse_workers.generic_pagination | default('') }}"
|
||||||
@@ -126,11 +140,6 @@ nginx_upstreams:
|
|||||||
servers: "{{ synapse_workers.user_dir | default('') }}"
|
servers: "{{ synapse_workers.user_dir | default('') }}"
|
||||||
locations:
|
locations:
|
||||||
- name: '~ ^/_matrix/client/(r0|v3|unstable)/user_directory/search$'
|
- name: '~ ^/_matrix/client/(r0|v3|unstable)/user_directory/search$'
|
||||||
synapse_frontend_proxy:
|
|
||||||
servers: "{{ synapse_workers.frontend_proxy | default('') }}"
|
|
||||||
locations:
|
|
||||||
- name: '~ ^/_matrix/client/(r0|v3|unstable)/keys/upload'
|
|
||||||
- name: "{{ '~ ^/_matrix/client/(api/v1|r0|v3|unstable)/presence/[^/]+/status' if synapse_presence is defined and not synapse_presence else '' }}"
|
|
||||||
synapse_media_repository:
|
synapse_media_repository:
|
||||||
servers: "{{ synapse_workers.media_repository | default('') }}"
|
servers: "{{ synapse_workers.media_repository | default('') }}"
|
||||||
locations:
|
locations:
|
||||||
@@ -190,14 +199,25 @@ nginx_upstreams:
|
|||||||
|
|
||||||
nginx_maps:
|
nginx_maps:
|
||||||
sync:
|
sync:
|
||||||
var: "{{ 'arg_since' if synapse_workers.generic_sync is defined and synapse_workers.generic_init_sync is defined else '' }}"
|
var: "{{ 'arg_since' if synapse_workers.generic_sync is defined and synapse_workers.generic_init_sync is defined else '' }}"
|
||||||
rules:
|
rules:
|
||||||
default: synchrotron_balancer
|
default: synapse_generic_sync
|
||||||
"''": synchrotron_init
|
"''": synapse_generic_init_sync
|
||||||
locations:
|
locations:
|
||||||
- name: '~ ^/_matrix/client/(r0|v3)/sync$'
|
- name: '~ ^/_matrix/client/(r0|v3)/sync$'
|
||||||
additional_options:
|
additional_options:
|
||||||
- 'proxy_read_timeout 1h'
|
- 'proxy_read_timeout 1h'
|
||||||
|
mxid_localpart_urlparam:
|
||||||
|
var: arg_access_token
|
||||||
|
rules:
|
||||||
|
default: $arg_access_token
|
||||||
|
"'~syt_(?<username>.*?)_.*'": $username
|
||||||
|
mxid_localpart:
|
||||||
|
var: http_authorization
|
||||||
|
rules:
|
||||||
|
default: $http_authorization
|
||||||
|
"'~Bearer syt_(?<username>.*?)_.*'": $username
|
||||||
|
"''": $mxid_localpart_urlparam
|
||||||
|
|
||||||
nginx_servers:
|
nginx_servers:
|
||||||
- listen:
|
- listen:
|
||||||
@@ -225,14 +245,13 @@ nginx_servers:
|
|||||||
- synapse_main
|
- synapse_main
|
||||||
- matrix_media_repo
|
- matrix_media_repo
|
||||||
- synapse_media_repository
|
- synapse_media_repository
|
||||||
|
- synapse_generic_sync
|
||||||
|
- synapse_generic_init_sync
|
||||||
- synapse_generic_client
|
- synapse_generic_client
|
||||||
- synapse_generic_login
|
- synapse_generic_login
|
||||||
- synapse_generic_event_send
|
- synapse_generic_event_send
|
||||||
- synapse_generic_pagination
|
- synapse_generic_pagination
|
||||||
- synapse_user_dir
|
- synapse_user_dir
|
||||||
- synapse_frontend_proxy
|
|
||||||
- synchrotron_balancer
|
|
||||||
- synchrotron_init
|
|
||||||
- synapse_device_persister
|
- synapse_device_persister
|
||||||
- synapse_typing_persister
|
- synapse_typing_persister
|
||||||
- synapse_account_persister
|
- synapse_account_persister
|
||||||
|
|||||||
@@ -9,14 +9,4 @@ matrix_max_upload_size_mb: 100
|
|||||||
synapse_metrics: false
|
synapse_metrics: false
|
||||||
synapse_presence: true
|
synapse_presence: true
|
||||||
|
|
||||||
synchrotron_workers:
|
matrix_auto_join_rooms: []
|
||||||
balancer: generic_sync
|
|
||||||
init: generic_init_sync
|
|
||||||
|
|
||||||
persister_workers:
|
|
||||||
- event_persister
|
|
||||||
- typing_persister
|
|
||||||
- account_persister
|
|
||||||
- device_persister
|
|
||||||
- presence_persister
|
|
||||||
- receipt_persister
|
|
||||||
|
|||||||
@@ -14,6 +14,13 @@
|
|||||||
enabled: true
|
enabled: true
|
||||||
state: restarted
|
state: restarted
|
||||||
|
|
||||||
|
- name: Disable worker services
|
||||||
|
ansible.builtin.systemd:
|
||||||
|
name: "matrix-synapse-worker@{{ item }}.service"
|
||||||
|
state: stopped
|
||||||
|
enabled: false
|
||||||
|
loop: "{{ synapse_disable_worker_services }}"
|
||||||
|
|
||||||
- name: Config worker services
|
- name: Config worker services
|
||||||
ansible.builtin.systemd:
|
ansible.builtin.systemd:
|
||||||
daemon_reload: true
|
daemon_reload: true
|
||||||
@@ -21,3 +28,12 @@
|
|||||||
enabled: true
|
enabled: true
|
||||||
loop: "{{ synapse_worker_services }}"
|
loop: "{{ synapse_worker_services }}"
|
||||||
notify: Config matrix target
|
notify: Config matrix target
|
||||||
|
|
||||||
|
- name: Disable matrix-synchrotrons
|
||||||
|
ansible.builtin.systemd:
|
||||||
|
daemon_reload: true
|
||||||
|
name: matrix-synchrotron@{{ item }}.service
|
||||||
|
enabled: false
|
||||||
|
loop:
|
||||||
|
- balancer
|
||||||
|
- init
|
||||||
|
|||||||
53
roles/synapse/meta/argument_specs.yml
Normal file
53
roles/synapse/meta/argument_specs.yml
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
argument_specs:
|
||||||
|
main:
|
||||||
|
short_description: Matrix Synaspe
|
||||||
|
description: "Installs and configures a synapse server. Supports workers and matrix_synapse_shared_secret_auth"
|
||||||
|
options:
|
||||||
|
synapse_psql_user:
|
||||||
|
description: Postgres database username for synapse
|
||||||
|
type: str
|
||||||
|
required: true
|
||||||
|
synapse_psql_pw:
|
||||||
|
description: Postgres database password for synapse
|
||||||
|
type: str
|
||||||
|
required: true
|
||||||
|
synapse_psql_db:
|
||||||
|
description: Postgres database name for synapse
|
||||||
|
type: str
|
||||||
|
required: false
|
||||||
|
default: "{{ synapse_psql_user }}"
|
||||||
|
synapse_psql_host:
|
||||||
|
description: Postgres database server hostname
|
||||||
|
type: str
|
||||||
|
required: false
|
||||||
|
default: localhost
|
||||||
|
|
||||||
|
matrix_max_upload_size_mb:
|
||||||
|
description: Maximum file upload size for synapse in megabytes
|
||||||
|
type: int
|
||||||
|
required: false
|
||||||
|
default: 100
|
||||||
|
matrix_auto_join_rooms:
|
||||||
|
description: A list of room aliases new users will be joined to automatically
|
||||||
|
type: list
|
||||||
|
required: false
|
||||||
|
default: []
|
||||||
|
|
||||||
|
matrix_signing_key:
|
||||||
|
description: Matrix federation signing key. Will use auto-generated one if not defined.
|
||||||
|
type: str
|
||||||
|
required: false
|
||||||
|
|
||||||
|
synapse_metrics:
|
||||||
|
description: Whether to enable prometheus metrics listener on port 9656
|
||||||
|
type: bool
|
||||||
|
required: false
|
||||||
|
default: false
|
||||||
|
|
||||||
|
synapse_presence:
|
||||||
|
description: Whether to enable presence detection on synapse. If disabled all users will be shown as permanently offline.
|
||||||
|
type: bool
|
||||||
|
required: false
|
||||||
|
default: true
|
||||||
@@ -29,6 +29,7 @@
|
|||||||
- listeners
|
- listeners
|
||||||
- server_name
|
- server_name
|
||||||
- url_preview
|
- url_preview
|
||||||
|
- autojoin
|
||||||
notify: Config matrix target
|
notify: Config matrix target
|
||||||
|
|
||||||
- name: Ensure synapse configs including secrets is in place
|
- name: Ensure synapse configs including secrets is in place
|
||||||
@@ -43,16 +44,6 @@
|
|||||||
- general
|
- general
|
||||||
notify: Config matrix target
|
notify: Config matrix target
|
||||||
|
|
||||||
- name: Ensure autojoin config is in place
|
|
||||||
ansible.builtin.template:
|
|
||||||
src: conf.d/autojoin.yaml.j2
|
|
||||||
dest: /etc/matrix-synapse/conf.d/autojoin.yaml
|
|
||||||
owner: matrix-synapse
|
|
||||||
group: nogroup
|
|
||||||
mode: 0644
|
|
||||||
when: matrix_auto_join_rooms is defined
|
|
||||||
notify: Config matrix target
|
|
||||||
|
|
||||||
- name: Ensure password provider config is in place
|
- name: Ensure password provider config is in place
|
||||||
ansible.builtin.template:
|
ansible.builtin.template:
|
||||||
src: conf.d/password_providers.yaml.j2
|
src: conf.d/password_providers.yaml.j2
|
||||||
|
|||||||
@@ -1,23 +0,0 @@
|
|||||||
---
|
|
||||||
|
|
||||||
- name: Ensure workdir exists for matrix-synchrotron-{{ item }}
|
|
||||||
ansible.builtin.file:
|
|
||||||
path: /opt/matrix-synchrotron/{{ item }}
|
|
||||||
state: directory
|
|
||||||
mode: 0755
|
|
||||||
|
|
||||||
- name: Ensure config in place for matrix-synchrotron-{{ item }}
|
|
||||||
ansible.builtin.template:
|
|
||||||
src: matrix-synchrotron-config.yaml.j2
|
|
||||||
dest: /opt/matrix-synchrotron/{{ item }}/config.yaml.ansibled
|
|
||||||
mode: 0644
|
|
||||||
notify: Config synapse service
|
|
||||||
register: config
|
|
||||||
|
|
||||||
- name: Copy config to final destination for matrix-synchrotron-{{ item }}
|
|
||||||
ansible.builtin.copy:
|
|
||||||
src: /opt/matrix-synchrotron/{{ item }}/config.yaml.ansibled
|
|
||||||
dest: /opt/matrix-synchrotron/{{ item }}/config.yaml
|
|
||||||
remote_src: true
|
|
||||||
mode: 0644
|
|
||||||
when: config.changed
|
|
||||||
@@ -1,53 +1,13 @@
|
|||||||
---
|
---
|
||||||
|
|
||||||
- name: Install git and golang
|
- name: Ensure matrix-synchrotron user not present
|
||||||
ansible.builtin.apt:
|
|
||||||
name:
|
|
||||||
- git
|
|
||||||
- golang
|
|
||||||
|
|
||||||
- name: Create matrix-synchrotron user
|
|
||||||
ansible.builtin.user:
|
ansible.builtin.user:
|
||||||
name: matrix-synchrotron
|
name: matrix-synchrotron
|
||||||
system: true
|
state: absent
|
||||||
home: /opt/matrix-synchrotron
|
remove: true
|
||||||
shell: /bin/false
|
|
||||||
|
|
||||||
- name: Install matrix-synchrotron
|
- name: Ensure matrix-synchrotron unit not present
|
||||||
become_user: matrix-synchrotron
|
ansible.builtin.file:
|
||||||
block:
|
path: /etc/systemd/system/matrix-synchrotron@.service
|
||||||
- name: Clone matrix-synchrotron git repo
|
state: absent
|
||||||
ansible.builtin.git:
|
notify: Disable matrix-synchrotrons
|
||||||
repo: https://github.com/Sorunome/matrix-synchrotron-balancer.git
|
|
||||||
dest: /opt/matrix-synchrotron/src
|
|
||||||
force: true
|
|
||||||
register: install
|
|
||||||
|
|
||||||
- name: Build matrix-synchrotron
|
|
||||||
ansible.builtin.command: go build
|
|
||||||
args:
|
|
||||||
chdir: /opt/matrix-synchrotron/src
|
|
||||||
when: install.changed
|
|
||||||
notify: Config synapse service
|
|
||||||
|
|
||||||
- name: Configure matrix-synchrotron(s)
|
|
||||||
ansible.builtin.include_tasks: matrix-synchrotron.yml
|
|
||||||
loop: "{{ synapse_synchrotrons }}"
|
|
||||||
loop_control:
|
|
||||||
extended: true
|
|
||||||
|
|
||||||
- name: Put systemd matrix-synchrotron unit in place
|
|
||||||
ansible.builtin.template:
|
|
||||||
src: systemd/matrix-synchrotron@.service.j2
|
|
||||||
dest: /etc/systemd/system/matrix-synchrotron@.service
|
|
||||||
mode: "644"
|
|
||||||
register: systemd_unit
|
|
||||||
|
|
||||||
- name: Enable systemd unit matrix-synchrotron-{{ item }}
|
|
||||||
ansible.builtin.systemd:
|
|
||||||
daemon_reload: true
|
|
||||||
name: matrix-synchrotron@{{ item }}.service
|
|
||||||
enabled: true
|
|
||||||
state: restarted
|
|
||||||
when: systemd_unit.changed
|
|
||||||
loop: "{{ synapse_synchrotrons }}"
|
|
||||||
|
|||||||
@@ -4,20 +4,44 @@
|
|||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
worker: "{{ worker_type }}-{{ worker_index | default('0') }}"
|
worker: "{{ worker_type }}-{{ worker_index | default('0') }}"
|
||||||
|
|
||||||
- name: Ensure config in place for {{ worker }}
|
- name: Enable worker {{ worker }}
|
||||||
ansible.builtin.template:
|
when: worker_state == 'present'
|
||||||
src: worker.yaml.j2
|
block:
|
||||||
dest: /etc/matrix-synapse/workers/{{ worker }}.yaml
|
- name: Ensure config in place for {{ worker }}
|
||||||
mode: 0644
|
ansible.builtin.template:
|
||||||
notify: Config worker services
|
src: worker.yaml.j2
|
||||||
|
dest: /etc/matrix-synapse/workers/{{ worker }}.yaml
|
||||||
|
mode: 0644
|
||||||
|
notify: Config worker services
|
||||||
|
|
||||||
- name: Ensure logging config in place for {{ worker }}
|
- name: Ensure logging config in place for {{ worker }}
|
||||||
ansible.builtin.template:
|
ansible.builtin.template:
|
||||||
src: log.yaml.j2
|
src: log.yaml.j2
|
||||||
dest: /etc/matrix-synapse/worker-logs/{{ worker }}-log.yaml
|
dest: /etc/matrix-synapse/worker-logs/{{ worker }}-log.yaml
|
||||||
mode: 0644
|
mode: 0644
|
||||||
notify: Config worker services
|
notify: Config worker services
|
||||||
|
|
||||||
- name: Add worker to synapse_worker_services variable
|
- name: Add worker to synapse_worker_services variable
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
synapse_worker_services: "{{ synapse_worker_services + [worker] }}"
|
synapse_worker_services: "{{ synapse_worker_services + [worker] }}"
|
||||||
|
|
||||||
|
|
||||||
|
- name: Disable worker {{ worker }}
|
||||||
|
when: worker_state == 'absent'
|
||||||
|
block:
|
||||||
|
- name: Notify the user
|
||||||
|
ansible.builtin.debug:
|
||||||
|
msg: "Disabling worker {{ worker }}! Make sure to remove it from your synapse_workers."
|
||||||
|
|
||||||
|
- name: Ensure worker config files not present
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: /etc/matrix-synapse/{{ item }}.yaml
|
||||||
|
state: absent
|
||||||
|
notify: Disable worker services
|
||||||
|
loop:
|
||||||
|
- workers/{{ worker }}
|
||||||
|
- worker-logs/{{ worker }}-log
|
||||||
|
|
||||||
|
- name: Add worker to synapse_disable_worker_services
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
synapse_disable_worker_services: "{{ synapse_worker_services + [worker] }}"
|
||||||
|
|||||||
@@ -5,15 +5,20 @@
|
|||||||
worker_type: "{{ synapse_worker.key }}"
|
worker_type: "{{ synapse_worker.key }}"
|
||||||
|
|
||||||
- name: Include default variables
|
- name: Include default variables
|
||||||
ansible.builtin.include_vars: defaults.yml
|
ansible.builtin.include_vars: workers/defaults.yml
|
||||||
|
|
||||||
- name: Include variables for {{ worker_type }}
|
- name: Include variables for {{ worker_type }}
|
||||||
ansible.builtin.include_vars: "{{ item }}"
|
ansible.builtin.include_vars: "{{ item }}"
|
||||||
with_first_found:
|
with_first_found:
|
||||||
- files:
|
- files:
|
||||||
- "{{ worker_type }}.yml"
|
- "workers/{{ worker_type }}.yml"
|
||||||
skip: true
|
skip: true
|
||||||
|
|
||||||
|
- name: Warn of legacy workers
|
||||||
|
ansible.builtin.debug:
|
||||||
|
msg: "You have a deprecated worker type {{ worker_type }} defined. You should remove it from synapse_workers."
|
||||||
|
when: worker_state == 'absent'
|
||||||
|
|
||||||
- name: Reset worker_ports variable
|
- name: Reset worker_ports variable
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
worker_ports: []
|
worker_ports: []
|
||||||
@@ -33,8 +38,3 @@
|
|||||||
- name: Include worker instance tasks for {{ worker_type }}
|
- name: Include worker instance tasks for {{ worker_type }}
|
||||||
ansible.builtin.include_tasks: worker_instance.yml
|
ansible.builtin.include_tasks: worker_instance.yml
|
||||||
when: worker_ports|length == 0
|
when: worker_ports|length == 0
|
||||||
|
|
||||||
- name: Append synchrotron variable
|
|
||||||
ansible.builtin.set_fact:
|
|
||||||
synapse_synchrotrons: "{{ synapse_synchrotrons + [synchrotron_type] }}"
|
|
||||||
when: synchrotron_type is defined and synchrotron_type not in synapse_synchrotrons
|
|
||||||
|
|||||||
@@ -25,21 +25,6 @@
|
|||||||
- name: Initialize synapse worker vars
|
- name: Initialize synapse worker vars
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
synapse_worker_services: []
|
synapse_worker_services: []
|
||||||
synapse_synchrotrons: []
|
|
||||||
|
|
||||||
- name: Ensure worker pidfile dir in /run exists
|
|
||||||
ansible.builtin.file:
|
|
||||||
path: /run/matrix-synapse/
|
|
||||||
state: directory
|
|
||||||
owner: matrix-synapse
|
|
||||||
group: nogroup
|
|
||||||
mode: 0755
|
|
||||||
|
|
||||||
- name: Ensure tmpfiles config for pidfile dir in place
|
|
||||||
ansible.builtin.template:
|
|
||||||
src: tmpfiles-matrix-synapse.conf.j2
|
|
||||||
dest: /etc/tmpfiles.d/matrix-synapse.conf
|
|
||||||
mode: 0644
|
|
||||||
|
|
||||||
- name: Configure workers
|
- name: Configure workers
|
||||||
ansible.builtin.include_tasks: worker_type.yml
|
ansible.builtin.include_tasks: worker_type.yml
|
||||||
@@ -47,6 +32,15 @@
|
|||||||
loop_control:
|
loop_control:
|
||||||
loop_var: synapse_worker
|
loop_var: synapse_worker
|
||||||
|
|
||||||
- name: Configure synchrotron balancer
|
- name: Ensure worker pidfile dir in /run not present (legacy)
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: /run/matrix-synapse/
|
||||||
|
state: absent
|
||||||
|
|
||||||
|
- name: Ensure tmpfiles config for pidfile dir not present (legacy)
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: /etc/tmpfiles.d/matrix-synapse.conf
|
||||||
|
state: absent
|
||||||
|
|
||||||
|
- name: Ensure synchrotron balancer removed (legacy)
|
||||||
ansible.builtin.include_tasks: matrix-synchrotrons.yml
|
ansible.builtin.include_tasks: matrix-synchrotrons.yml
|
||||||
when: synapse_synchrotrons | length != 0
|
|
||||||
|
|||||||
@@ -1,6 +1,3 @@
|
|||||||
# {{ ansible_managed }}
|
# {{ ansible_managed }}
|
||||||
|
|
||||||
auto_join_rooms:
|
auto_join_rooms: {{ matrix_auto_join_rooms }}
|
||||||
{% for room_id in matrix_auto_join_rooms %}
|
|
||||||
- "{{ room_id }}"
|
|
||||||
{% endfor %}
|
|
||||||
|
|||||||
@@ -12,5 +12,3 @@ use_presence: {{ synapse_presence }}
|
|||||||
enable_media_repo: {{ matrix_media_repo_server is not defined and 'media_repository' not in synapse_workers }}
|
enable_media_repo: {{ matrix_media_repo_server is not defined and 'media_repository' not in synapse_workers }}
|
||||||
retention:
|
retention:
|
||||||
enabled: true
|
enabled: true
|
||||||
experimental_features:
|
|
||||||
msc2716_enabled: true
|
|
||||||
|
|||||||
@@ -6,7 +6,10 @@ redis:
|
|||||||
notify_appservices_from_worker: appservice-0
|
notify_appservices_from_worker: appservice-0
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if 'pusher' in synapse_workers %}
|
{% if 'pusher' in synapse_workers %}
|
||||||
start_pushers: false
|
pusher_instances:
|
||||||
|
{% for port in synapse_workers.pusher %}
|
||||||
|
- pusher-{{ loop.index0 }}
|
||||||
|
{% endfor %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if 'user_dir' in synapse_workers %}
|
{% if 'user_dir' in synapse_workers %}
|
||||||
update_user_directory_from_worker: user_dir-0
|
update_user_directory_from_worker: user_dir-0
|
||||||
@@ -15,9 +18,11 @@ update_user_directory_from_worker: user_dir-0
|
|||||||
|
|
||||||
{% if 'event_persister' in synapse_workers or 'typing_persister' in synapse_workers or 'account_persister' in synapse_workers or 'device_persister' in synapse_workers or 'presence_persister' in synapse_workers or 'receipt_persister' in synapse_workers %}
|
{% if 'event_persister' in synapse_workers or 'typing_persister' in synapse_workers or 'account_persister' in synapse_workers or 'device_persister' in synapse_workers or 'presence_persister' in synapse_workers or 'receipt_persister' in synapse_workers %}
|
||||||
instance_map:
|
instance_map:
|
||||||
|
main:
|
||||||
|
host: localhost
|
||||||
|
port: 9093
|
||||||
|
|
||||||
{% for persister_type in persister_workers %}
|
{% for persister_type in persister_workers %}
|
||||||
|
|
||||||
{% if persister_type in synapse_workers %}
|
{% if persister_type in synapse_workers %}
|
||||||
{% for port in synapse_workers[persister_type] %}
|
{% for port in synapse_workers[persister_type] %}
|
||||||
{{ persister_type }}-{{ loop.index0 }}:
|
{{ persister_type }}-{{ loop.index0 }}:
|
||||||
@@ -25,7 +30,6 @@ instance_map:
|
|||||||
port: {{ port }}
|
port: {{ port }}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
stream_writers:
|
stream_writers:
|
||||||
@@ -78,13 +82,8 @@ run_background_tasks_on: background_tasks-0
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if 'federation_sender' in synapse_workers %}
|
{% if 'federation_sender' in synapse_workers %}
|
||||||
send_federation: false
|
|
||||||
|
|
||||||
{% if synapse_workers.federation_sender|length > 1 %}
|
|
||||||
federation_sender_instances:
|
federation_sender_instances:
|
||||||
{% for port in synapse_workers.federation_sender %}
|
{% for port in synapse_workers.federation_sender %}
|
||||||
- federation_sender-{{ loop.index0 }}
|
- federation_sender-{{ loop.index0 }}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% endif %}
|
|
||||||
|
|||||||
@@ -1,12 +0,0 @@
|
|||||||
# {{ ansible_managed }}
|
|
||||||
homeserver_url: http://localhost:8008 # homeserver URL for the whoami request
|
|
||||||
listener: localhost:{{ 8183 + ansible_loop.index0 }} # host:port to listen to
|
|
||||||
|
|
||||||
synchrotrons:
|
|
||||||
{% for port in synapse_workers[synchrotron_workers[item]] %}
|
|
||||||
- address: 127.0.0.1:{{ port }}
|
|
||||||
pid_file: /run/matrix-synapse/{{ synchrotron_workers[item] }}-{{ loop.index0 }}.pid
|
|
||||||
{% endfor %}
|
|
||||||
|
|
||||||
balancer:
|
|
||||||
interval: 2
|
|
||||||
@@ -10,12 +10,10 @@ After=matrix-synapse.service
|
|||||||
[Service]
|
[Service]
|
||||||
Type=notify
|
Type=notify
|
||||||
NotifyAccess=main
|
NotifyAccess=main
|
||||||
PIDFile=/run/matrix-synapse/%i.pid
|
|
||||||
User=matrix-synapse
|
User=matrix-synapse
|
||||||
WorkingDirectory=/var/lib/matrix-synapse
|
WorkingDirectory=/var/lib/matrix-synapse
|
||||||
EnvironmentFile=-/etc/default/matrix-synapse
|
EnvironmentFile=-/etc/default/matrix-synapse
|
||||||
ExecStart=/opt/venvs/matrix-synapse/bin/python -m synapse.app.generic_worker --config-path=/etc/matrix-synapse/homeserver.yaml --config-path=/etc/matrix-synapse/conf.d/ --config-path=/etc/matrix-synapse/workers/%i.yaml
|
ExecStart=/opt/venvs/matrix-synapse/bin/python -m synapse.app.generic_worker --config-path=/etc/matrix-synapse/homeserver.yaml --config-path=/etc/matrix-synapse/conf.d/ --config-path=/etc/matrix-synapse/workers/%i.yaml
|
||||||
ExecStartPost=/bin/sh -c "echo $MAINPID > /run/matrix-synapse/%i.pid"
|
|
||||||
ExecReload=/bin/kill -HUP $MAINPID
|
ExecReload=/bin/kill -HUP $MAINPID
|
||||||
Restart=always
|
Restart=always
|
||||||
RestartSec=3
|
RestartSec=3
|
||||||
|
|||||||
@@ -1,17 +0,0 @@
|
|||||||
# {{ ansible_managed }}
|
|
||||||
|
|
||||||
[Unit]
|
|
||||||
Description=Matrix Synchrotron %i
|
|
||||||
After=matrix-synapse.service
|
|
||||||
PartOf=matrix-synapse.service
|
|
||||||
|
|
||||||
[Service]
|
|
||||||
Type=simple
|
|
||||||
User=matrix-synchrotron
|
|
||||||
WorkingDirectory=/opt/matrix-synchrotron/%i
|
|
||||||
ExecStart=/opt/matrix-synchrotron/src/matrix-synchrotron-balancer
|
|
||||||
Restart=always
|
|
||||||
RestartSec=3
|
|
||||||
|
|
||||||
[Install]
|
|
||||||
WantedBy=matrix-synapse.service
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
d /run/matrix-synapse 0755 matrix-synapse nogroup - -
|
|
||||||
@@ -2,10 +2,6 @@
|
|||||||
worker_app: synapse.app.{{ worker_app }}
|
worker_app: synapse.app.{{ worker_app }}
|
||||||
worker_name: {{ worker }}
|
worker_name: {{ worker }}
|
||||||
|
|
||||||
# The replication listener on the synapse to talk to.
|
|
||||||
worker_replication_host: 127.0.0.1
|
|
||||||
worker_replication_http_port: 9093
|
|
||||||
|
|
||||||
worker_log_config: /etc/matrix-synapse/worker-logs/{{ worker }}-log.yaml
|
worker_log_config: /etc/matrix-synapse/worker-logs/{{ worker }}-log.yaml
|
||||||
{% if worker_port is defined and worker_listeners|length !=0 or synapse_metrics %}
|
{% if worker_port is defined and worker_listeners|length !=0 or synapse_metrics %}
|
||||||
worker_listeners:
|
worker_listeners:
|
||||||
@@ -24,6 +20,3 @@ worker_listeners:
|
|||||||
bind_addresses: ['0.0.0.0'] # Don't bind to multiple addresses
|
bind_addresses: ['0.0.0.0'] # Don't bind to multiple addresses
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if worker_app == 'frontend_proxy' %}
|
|
||||||
worker_main_http_uri: http://localhost:8008
|
|
||||||
{% endif %}
|
|
||||||
|
|||||||
@@ -1,4 +0,0 @@
|
|||||||
---
|
|
||||||
|
|
||||||
worker_app: federation_sender
|
|
||||||
worker_listeners: []
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
---
|
|
||||||
|
|
||||||
worker_app: frontend_proxy
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
---
|
|
||||||
|
|
||||||
synchrotron_type: init
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
---
|
|
||||||
|
|
||||||
synchrotron_type: balancer
|
|
||||||
9
roles/synapse/vars/main.yml
Normal file
9
roles/synapse/vars/main.yml
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
persister_workers:
|
||||||
|
- event_persister
|
||||||
|
- typing_persister
|
||||||
|
- account_persister
|
||||||
|
- device_persister
|
||||||
|
- presence_persister
|
||||||
|
- receipt_persister
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
---
|
---
|
||||||
|
|
||||||
|
worker_state: present
|
||||||
worker_app: generic_worker
|
worker_app: generic_worker
|
||||||
worker_listeners:
|
worker_listeners:
|
||||||
- client
|
- client
|
||||||
3
roles/synapse/vars/workers/federation_sender.yml
Normal file
3
roles/synapse/vars/workers/federation_sender.yml
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
worker_listeners: []
|
||||||
4
roles/synapse/vars/workers/frontend_proxy.yml
Normal file
4
roles/synapse/vars/workers/frontend_proxy.yml
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
# LEGACY
|
||||||
|
worker_state: absent
|
||||||
@@ -1,4 +1,3 @@
|
|||||||
---
|
---
|
||||||
|
|
||||||
worker_app: pusher
|
|
||||||
worker_listeners: []
|
worker_listeners: []
|
||||||
Reference in New Issue
Block a user