Compare commits

..

6 Commits

Author SHA1 Message Date
uumas
323ec0152f Move todo to issues 2023-04-25 21:42:45 +03:00
uumas
979a6814b0 Update worker endpoints 2023-04-25 21:40:58 +03:00
uumas
a4b65f5b50 Migrate pusher and federations_sender to generic_worker 2023-04-25 21:40:43 +03:00
uumas
d1bbd974ab Remove frontend proxy worker 2023-04-25 21:39:51 +03:00
uumas
0033ffc405 Make it possible to remove legacy workers 2023-04-25 21:35:38 +03:00
uumas
46dc53580e Cleanup synchrotron balancers 2023-04-25 20:30:59 +03:00
14 changed files with 75 additions and 51 deletions

View File

@@ -3,7 +3,4 @@
Roles for matrix services
# To do
- Add argument spec validation
- Move ldap auth provider from password providers to collections
- Make updates optional (use state: present instead of state: latest unless requested)
- Only restart extras being changed, not all
See [issues](https://git.uumas.fi/uumas/ansible-matrix/issues)

View File

@@ -1,5 +1,6 @@
---
# Worker endpoints last updated on 2023-04-25
nginx_upstreams:
synapse_main:
servers:
@@ -43,6 +44,8 @@ nginx_upstreams:
- name: '~ ^/_matrix/client/(api/v1|r0|v3|unstable)/rooms/.*/members$'
- name: '~ ^/_matrix/client/(api/v1|r0|v3|unstable)/rooms/.*/state$'
- name: '~ ^/_matrix/client/v1/rooms/.*/hierarchy$'
- name: '~ ^/_matrix/client/(v1|unstable)/rooms/.*/relations/'
- name: '~ ^/_matrix/client/v1/rooms/.*/threads$'
- name: '~ ^/_matrix/client/unstable/org.matrix.msc2716/rooms/.*/batch_send$'
- name: '~ ^/_matrix/client/unstable/im.nheko.summary/rooms/.*/summary$'
- name: '~ ^/_matrix/client/(r0|v3|unstable)/account/3pid$'
@@ -52,7 +55,12 @@ nginx_upstreams:
- 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)/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/(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$'
additional_options:
@@ -60,12 +68,15 @@ nginx_upstreams:
- name: '~ ^/_matrix/client/(api/v1|r0|v3|unstable)/keys/changes$'
- name: '~ ^/_matrix/client/(r0|v3|unstable)/keys/claim$'
- name: '~ ^/_matrix/client/(r0|v3|unstable)/room_keys/'
- name: '~ ^/_matrix/client/(r0|v3|unstable)/keys/upload/'
synapse_generic_login:
servers: "{{ synapse_workers.generic_login | default('') }}"
locations:
- name: '~ ^/_matrix/client/(api/v1|r0|unstable|v3)/login$'
- 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/(r0|v3|unstable)/password_policy$'
# SSO
- name: '~ ^/_matrix/client/(api/v1|r0|v3|unstable)/login/sso/redirect'
- name: '~ ^/_synapse/client/pick_idp$'
@@ -96,6 +107,7 @@ nginx_upstreams:
- name: '~ ^/_matrix/federation/(v1|v2)/send_leave/'
- name: '~ ^/_matrix/federation/(v1|v2)/invite/'
- 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/user/devices/'
- name: '~ ^/_matrix/key/v2/query'
@@ -118,6 +130,7 @@ nginx_upstreams:
- name: '~ ^/_matrix/client/(api/v1|r0|v3|unstable)/join/'
additional_options:
- 'proxy_read_timeout 1h'
- name: '~ ^/_matrix/client/(api/v1|r0|v3|unstable)/knock/'
- name: '~ ^/_matrix/client/(api/v1|r0|v3|unstable)/profile/'
synapse_generic_pagination:
servers: "{{ synapse_workers.generic_pagination | default('') }}"
@@ -128,11 +141,6 @@ nginx_upstreams:
servers: "{{ synapse_workers.user_dir | default('') }}"
locations:
- 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:
servers: "{{ synapse_workers.media_repository | default('') }}"
locations:
@@ -245,7 +253,6 @@ nginx_servers:
- synapse_generic_event_send
- synapse_generic_pagination
- synapse_user_dir
- synapse_frontend_proxy
- synapse_device_persister
- synapse_typing_persister
- synapse_account_persister

View File

@@ -14,6 +14,13 @@
enabled: true
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
ansible.builtin.systemd:
daemon_reload: true
@@ -27,4 +34,6 @@
daemon_reload: true
name: matrix-synchrotron@{{ item }}.service
enabled: false
loop: "{{ synapse_synchrotrons }}"
loop:
- balancer
- init

View File

@@ -4,20 +4,44 @@
ansible.builtin.set_fact:
worker: "{{ worker_type }}-{{ worker_index | default('0') }}"
- name: Ensure config in place for {{ worker }}
- name: Enable worker {{ worker }}
when: worker_state == 'present'
block:
- name: Ensure config in place for {{ worker }}
ansible.builtin.template:
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:
src: log.yaml.j2
dest: /etc/matrix-synapse/worker-logs/{{ worker }}-log.yaml
mode: 0644
notify: Config worker services
- name: Add worker to synapse_worker_services variable
- name: Add worker to synapse_worker_services variable
ansible.builtin.set_fact:
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] }}"

View File

@@ -14,6 +14,11 @@
- "{{ worker_type }}.yml"
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
ansible.builtin.set_fact:
worker_ports: []
@@ -33,8 +38,3 @@
- name: Include worker instance tasks for {{ worker_type }}
ansible.builtin.include_tasks: worker_instance.yml
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

View File

@@ -25,7 +25,6 @@
- name: Initialize synapse worker vars
ansible.builtin.set_fact:
synapse_worker_services: []
synapse_synchrotrons: []
- name: Configure workers
ansible.builtin.include_tasks: worker_type.yml
@@ -45,4 +44,3 @@
- name: Ensure synchrotron balancer removed (legacy)
ansible.builtin.include_tasks: matrix-synchrotrons.yml
when: synapse_synchrotrons | length != 0

View File

@@ -6,7 +6,10 @@ redis:
notify_appservices_from_worker: appservice-0
{% endif %}
{% if 'pusher' in synapse_workers %}
start_pushers: false
pusher_instances:
{% for port in synapse_workers.pusher %}
- pusher-{{ loop.index0 }}
{% endfor %}
{% endif %}
{% if 'user_dir' in synapse_workers %}
update_user_directory_from_worker: user_dir-0
@@ -78,13 +81,8 @@ run_background_tasks_on: background_tasks-0
{% endif %}
{% if 'federation_sender' in synapse_workers %}
send_federation: false
{% if synapse_workers.federation_sender|length > 1 %}
federation_sender_instances:
{% for port in synapse_workers.federation_sender %}
- federation_sender-{{ loop.index0 }}
{% endfor %}
{% endif %}
{% endif %}

View File

@@ -24,6 +24,3 @@ worker_listeners:
bind_addresses: ['0.0.0.0'] # Don't bind to multiple addresses
{% endif %}
{% endif %}
{% if worker_app == 'frontend_proxy' %}
worker_main_http_uri: http://localhost:8008
{% endif %}

View File

@@ -1,5 +1,6 @@
---
worker_state: present
worker_app: generic_worker
worker_listeners:
- client

View File

@@ -1,4 +1,3 @@
---
worker_app: federation_sender
worker_listeners: []

View File

@@ -1,3 +1,4 @@
---
worker_app: frontend_proxy
# LEGACY
worker_state: absent

View File

@@ -1,3 +0,0 @@
---
synchrotron_type: init

View File

@@ -1,3 +0,0 @@
---
synchrotron_type: balancer

View File

@@ -1,4 +1,3 @@
---
worker_app: pusher
worker_listeners: []