2022-02-05 22:32:54 +02:00
|
|
|
---
|
2021-02-15 11:25:35 +02:00
|
|
|
# Below is a huge hack for dynamically building a list of workers and finally assigning it to `matrix_synapse_workers_enabled_list`.
|
|
|
|
#
|
|
|
|
# set_fact within a loop does not work reliably in Ansible (it only executes on the first iteration for some reason),
|
|
|
|
# so we're forced to do something much uglier.
|
|
|
|
|
2024-01-16 17:17:24 +02:00
|
|
|
- name: Build room workers
|
|
|
|
ansible.builtin.set_fact:
|
|
|
|
worker:
|
|
|
|
id: "room-worker-{{ item }}"
|
|
|
|
name: "matrix-synapse-worker-room-{{ item }}"
|
|
|
|
type: 'room_worker'
|
|
|
|
app: 'generic_worker'
|
|
|
|
webserving: true
|
|
|
|
port: "{{ matrix_synapse_workers_room_workers_port_range_start + item }}"
|
|
|
|
metrics_port: "{{ matrix_synapse_workers_room_workers_metrics_range_start + item }}"
|
|
|
|
register: "matrix_synapse_workers_list_results_room_workers"
|
|
|
|
loop: "{{ range(0, matrix_synapse_workers_room_workers_count | int) | list }}"
|
|
|
|
|
|
|
|
- name: Build client sync workers
|
|
|
|
ansible.builtin.set_fact:
|
|
|
|
worker:
|
|
|
|
id: "sync-worker-{{ item }}"
|
|
|
|
name: "matrix-synapse-worker-sync-{{ item }}"
|
|
|
|
type: 'sync_worker'
|
|
|
|
app: 'generic_worker'
|
|
|
|
webserving: true
|
|
|
|
port: "{{ matrix_synapse_workers_sync_workers_port_range_start + item }}"
|
|
|
|
metrics_port: "{{ matrix_synapse_workers_sync_workers_metrics_range_start + item }}"
|
|
|
|
register: "matrix_synapse_workers_list_results_sync_workers"
|
|
|
|
loop: "{{ range(0, matrix_synapse_workers_sync_workers_count | int) | list }}"
|
|
|
|
|
|
|
|
- name: Build client reader workers
|
|
|
|
ansible.builtin.set_fact:
|
|
|
|
worker:
|
|
|
|
id: "client-reader-{{ item }}"
|
|
|
|
name: "matrix-synapse-worker-client-reader-{{ item }}"
|
|
|
|
type: 'client_reader'
|
|
|
|
app: 'generic_worker'
|
|
|
|
webserving: true
|
|
|
|
port: "{{ matrix_synapse_workers_client_reader_workers_port_range_start + item }}"
|
|
|
|
metrics_port: "{{ matrix_synapse_workers_client_reader_workers_metrics_range_start + item }}"
|
|
|
|
register: "matrix_synapse_workers_list_results_client_reader_workers"
|
|
|
|
loop: "{{ range(0, matrix_synapse_workers_client_reader_workers_count | int) | list }}"
|
|
|
|
|
|
|
|
- name: Build federation reader workers
|
|
|
|
ansible.builtin.set_fact:
|
|
|
|
worker:
|
|
|
|
id: "federation-reader-{{ item }}"
|
|
|
|
name: "matrix-synapse-worker-federation-reader-{{ item }}"
|
|
|
|
type: 'federation_reader'
|
|
|
|
app: 'generic_worker'
|
|
|
|
webserving: true
|
|
|
|
port: "{{ matrix_synapse_workers_federation_reader_workers_port_range_start + item }}"
|
|
|
|
metrics_port: "{{ matrix_synapse_workers_federation_reader_workers_metrics_range_start + item }}"
|
|
|
|
register: "matrix_synapse_workers_list_results_federation_reader_workers"
|
|
|
|
loop: "{{ range(0, matrix_synapse_workers_federation_reader_workers_count | int) | list }}"
|
|
|
|
|
2021-02-15 11:25:35 +02:00
|
|
|
- name: Build generic workers
|
2022-07-18 09:39:08 +02:00
|
|
|
ansible.builtin.set_fact:
|
2021-02-15 11:25:35 +02:00
|
|
|
worker:
|
2022-09-15 06:05:25 +02:00
|
|
|
id: "generic-worker-{{ item }}"
|
|
|
|
name: "matrix-synapse-worker-generic-{{ item }}"
|
2021-02-15 11:25:35 +02:00
|
|
|
type: 'generic_worker'
|
2022-09-15 06:05:25 +02:00
|
|
|
app: 'generic_worker'
|
|
|
|
webserving: true
|
2021-02-15 11:25:35 +02:00
|
|
|
port: "{{ matrix_synapse_workers_generic_workers_port_range_start + item }}"
|
|
|
|
metrics_port: "{{ matrix_synapse_workers_generic_workers_metrics_range_start + item }}"
|
|
|
|
register: "matrix_synapse_workers_list_results_generic_workers"
|
2022-07-18 11:28:39 +02:00
|
|
|
loop: "{{ range(0, matrix_synapse_workers_generic_workers_count | int) | list }}"
|
2021-02-15 11:25:35 +02:00
|
|
|
|
2022-09-15 06:05:25 +02:00
|
|
|
- name: Build stream writer workers
|
|
|
|
ansible.builtin.set_fact:
|
|
|
|
worker:
|
2022-09-15 11:46:41 +02:00
|
|
|
id: "stream-writer-{{ idx }}-{{ item.stream }}"
|
2023-05-19 17:26:05 +02:00
|
|
|
# Names must not include underscores. Certain stream writer streams (to_device, account_data, ..) do, so we fix them up.
|
2022-09-15 06:05:25 +02:00
|
|
|
name: "matrix-synapse-worker-stream-writer-{{ idx }}-{{ item.stream | replace('_', '-') }}"
|
|
|
|
type: 'stream_writer'
|
|
|
|
app: "generic_worker"
|
|
|
|
webserving: "{{ item.stream in matrix_synapse_workers_webserving_stream_writer_types }}"
|
|
|
|
stream_writer_stream: "{{ item.stream }}"
|
|
|
|
port: "{{ matrix_synapse_workers_stream_writer_workers_http_port_range_start + idx }}"
|
|
|
|
replication_port: "{{ matrix_synapse_workers_stream_writer_workers_replication_port_range_start + idx }}"
|
|
|
|
metrics_port: "{{ matrix_synapse_workers_stream_writer_workers_metrics_range_start + idx }}"
|
|
|
|
register: "matrix_synapse_workers_list_results_stream_writer_workers"
|
|
|
|
loop: "{{ matrix_synapse_workers_stream_writers }}"
|
|
|
|
loop_control:
|
|
|
|
index_var: idx
|
|
|
|
|
|
|
|
- name: Populate matrix_synapse_stream_writers from enabled stream writer workers list
|
|
|
|
ansible.builtin.set_fact:
|
2022-11-01 20:11:11 +02:00
|
|
|
matrix_synapse_stream_writers: "{{ matrix_synapse_stream_writers | combine({item.ansible_facts.worker.stream_writer_stream: [item.ansible_facts.worker.name]}, list_merge='append') }}"
|
2022-09-15 06:05:25 +02:00
|
|
|
with_items: "{{ matrix_synapse_workers_list_results_stream_writer_workers.results }}"
|
|
|
|
|
2021-02-15 11:25:35 +02:00
|
|
|
- name: Build federation sender workers
|
2022-07-18 09:39:08 +02:00
|
|
|
ansible.builtin.set_fact:
|
2021-02-15 11:25:35 +02:00
|
|
|
worker:
|
2022-09-15 06:05:25 +02:00
|
|
|
id: "federation-sender-{{ item }}"
|
|
|
|
name: "matrix-synapse-worker-federation-sender-{{ item }}"
|
2021-02-15 11:25:35 +02:00
|
|
|
type: 'federation_sender'
|
2023-01-17 15:55:49 +02:00
|
|
|
app: 'generic_worker'
|
2022-09-15 06:05:25 +02:00
|
|
|
webserving: false
|
2021-02-15 11:25:35 +02:00
|
|
|
port: 0
|
|
|
|
metrics_port: "{{ matrix_synapse_workers_federation_sender_workers_metrics_range_start + item }}"
|
|
|
|
register: "matrix_synapse_workers_list_results_federation_sender_workers"
|
2022-07-18 11:28:39 +02:00
|
|
|
loop: "{{ range(0, matrix_synapse_workers_federation_sender_workers_count | int) | list }}"
|
2021-02-15 11:25:35 +02:00
|
|
|
|
2022-09-15 07:13:08 +02:00
|
|
|
- name: Populate matrix_synapse_federation_sender_instances from enabled federation sender workers list
|
|
|
|
ansible.builtin.set_fact:
|
|
|
|
matrix_synapse_federation_sender_instances: "{{ matrix_synapse_federation_sender_instances + [item.ansible_facts.worker.name] }}"
|
|
|
|
with_items: "{{ matrix_synapse_workers_list_results_federation_sender_workers.results }}"
|
|
|
|
|
2021-02-15 11:25:35 +02:00
|
|
|
- name: Build pusher workers
|
2022-07-18 09:39:08 +02:00
|
|
|
ansible.builtin.set_fact:
|
2021-02-15 11:25:35 +02:00
|
|
|
worker:
|
2022-09-15 06:05:25 +02:00
|
|
|
id: "pusher-{{ item }}"
|
|
|
|
name: "matrix-synapse-worker-pusher-{{ item }}"
|
2021-02-15 11:25:35 +02:00
|
|
|
type: 'pusher'
|
2023-01-17 15:55:49 +02:00
|
|
|
app: 'generic_worker'
|
2022-09-15 06:05:25 +02:00
|
|
|
webserving: false
|
2021-02-15 11:25:35 +02:00
|
|
|
port: 0
|
|
|
|
metrics_port: "{{ matrix_synapse_workers_pusher_workers_metrics_range_start + item }}"
|
|
|
|
register: "matrix_synapse_workers_list_results_pusher_workers"
|
2022-07-18 11:28:39 +02:00
|
|
|
loop: "{{ range(0, matrix_synapse_workers_pusher_workers_count | int) | list }}"
|
2021-02-15 11:25:35 +02:00
|
|
|
|
|
|
|
# This type of worker can only have a count of 1, at most
|
|
|
|
- name: Build appservice workers
|
2022-07-18 09:39:08 +02:00
|
|
|
ansible.builtin.set_fact:
|
2021-02-15 11:25:35 +02:00
|
|
|
worker:
|
2022-09-15 06:05:25 +02:00
|
|
|
id: "appservice-{{ item }}"
|
|
|
|
name: "matrix-synapse-worker-appservice-{{ item }}"
|
2021-02-15 11:25:35 +02:00
|
|
|
type: 'appservice'
|
2022-09-15 09:00:57 +02:00
|
|
|
app: 'generic_worker'
|
2022-09-15 06:05:25 +02:00
|
|
|
webserving: false
|
2021-02-15 11:25:35 +02:00
|
|
|
port: 0
|
|
|
|
metrics_port: "{{ matrix_synapse_workers_appservice_workers_metrics_range_start + item }}"
|
|
|
|
register: "matrix_synapse_workers_list_results_appservice_workers"
|
2022-07-18 11:28:39 +02:00
|
|
|
loop: "{{ range(0, matrix_synapse_workers_appservice_workers_count | int) | list }}"
|
2021-02-15 11:25:35 +02:00
|
|
|
|
2022-09-15 09:00:57 +02:00
|
|
|
# This type of worker can only have a count of 1, at most
|
|
|
|
- name: Build user_dir workers
|
|
|
|
ansible.builtin.set_fact:
|
|
|
|
worker:
|
|
|
|
id: "user-dir-{{ item }}"
|
|
|
|
name: "matrix-synapse-worker-user-dir-{{ item }}"
|
|
|
|
type: 'user_dir'
|
|
|
|
app: 'generic_worker'
|
|
|
|
webserving: true
|
|
|
|
port: "{{ matrix_synapse_workers_user_dir_workers_port_range_start + item }}"
|
|
|
|
metrics_port: "{{ matrix_synapse_workers_user_dir_workers_metrics_range_start + item }}"
|
|
|
|
register: "matrix_synapse_workers_list_results_user_dir_workers"
|
|
|
|
loop: "{{ range(0, matrix_synapse_workers_user_dir_workers_count | int) | list }}"
|
|
|
|
|
2022-09-15 09:32:51 +02:00
|
|
|
# This type of worker can only have a count of 1, at most
|
|
|
|
- name: Build background workers
|
|
|
|
ansible.builtin.set_fact:
|
|
|
|
worker:
|
|
|
|
id: "background-{{ item }}"
|
|
|
|
name: "matrix-synapse-worker-background-{{ item }}"
|
|
|
|
type: 'background'
|
|
|
|
app: 'generic_worker'
|
|
|
|
webserving: false
|
|
|
|
port: 0
|
|
|
|
metrics_port: "{{ matrix_synapse_workers_background_workers_metrics_range_start + item }}"
|
|
|
|
register: "matrix_synapse_workers_list_results_background_workers"
|
|
|
|
loop: "{{ range(0, matrix_synapse_workers_background_workers_count | int) | list }}"
|
|
|
|
|
2021-02-15 11:25:35 +02:00
|
|
|
- name: Build media_repository workers
|
2022-07-18 09:39:08 +02:00
|
|
|
ansible.builtin.set_fact:
|
2021-02-15 11:25:35 +02:00
|
|
|
worker:
|
2022-09-15 06:05:25 +02:00
|
|
|
id: "media-repository-{{ item }}"
|
|
|
|
name: "matrix-synapse-worker-media-repository-{{ item }}"
|
2021-02-15 11:25:35 +02:00
|
|
|
type: 'media_repository'
|
2022-09-15 06:05:25 +02:00
|
|
|
app: 'media_repository'
|
|
|
|
webserving: true
|
2021-02-15 11:25:35 +02:00
|
|
|
port: "{{ matrix_synapse_workers_media_repository_workers_port_range_start + item }}"
|
|
|
|
metrics_port: "{{ matrix_synapse_workers_media_repository_workers_metrics_range_start + item }}"
|
|
|
|
register: "matrix_synapse_workers_list_results_media_repository_workers"
|
2022-07-18 11:28:39 +02:00
|
|
|
loop: "{{ range(0, matrix_synapse_workers_media_repository_workers_count | int) | list }}"
|
2021-02-15 11:25:35 +02:00
|
|
|
|
2022-07-18 09:39:08 +02:00
|
|
|
- ansible.builtin.set_fact:
|
2022-07-18 10:22:05 +02:00
|
|
|
matrix_synapse_dynamic_workers_list: "{{ matrix_synapse_dynamic_workers_list | default([]) + [item.ansible_facts.worker] }}"
|
2021-02-15 11:25:35 +02:00
|
|
|
with_items: |
|
|
|
|
{{
|
2024-01-16 19:13:51 +02:00
|
|
|
matrix_synapse_workers_list_results_room_workers.results
|
|
|
|
+
|
|
|
|
matrix_synapse_workers_list_results_sync_workers.results
|
|
|
|
+
|
|
|
|
matrix_synapse_workers_list_results_client_reader_workers.results
|
|
|
|
+
|
|
|
|
matrix_synapse_workers_list_results_federation_reader_workers.results
|
|
|
|
+
|
2021-02-15 11:25:35 +02:00
|
|
|
matrix_synapse_workers_list_results_generic_workers.results
|
|
|
|
+
|
2022-09-15 06:05:25 +02:00
|
|
|
matrix_synapse_workers_list_results_stream_writer_workers.results
|
|
|
|
+
|
2021-02-15 11:25:35 +02:00
|
|
|
matrix_synapse_workers_list_results_federation_sender_workers.results
|
|
|
|
+
|
|
|
|
matrix_synapse_workers_list_results_pusher_workers.results
|
|
|
|
+
|
|
|
|
matrix_synapse_workers_list_results_appservice_workers.results
|
|
|
|
+
|
2022-09-15 09:00:57 +02:00
|
|
|
matrix_synapse_workers_list_results_user_dir_workers.results
|
|
|
|
+
|
2021-02-15 11:25:35 +02:00
|
|
|
matrix_synapse_workers_list_results_media_repository_workers.results
|
2022-09-15 09:32:51 +02:00
|
|
|
+
|
|
|
|
matrix_synapse_workers_list_results_background_workers.results
|
2021-02-15 11:25:35 +02:00
|
|
|
}}
|
|
|
|
|
2022-07-18 09:39:08 +02:00
|
|
|
- ansible.builtin.set_fact:
|
2021-02-15 11:25:35 +02:00
|
|
|
matrix_synapse_workers_enabled_list: "{{ matrix_synapse_dynamic_workers_list }}"
|