2022-02-05 20:32:54 +00:00
|
|
|
---
|
2021-02-15 09:25:35 +00: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.
|
|
|
|
|
|
|
|
- name: Build generic workers
|
2022-07-18 07:39:08 +00:00
|
|
|
ansible.builtin.set_fact:
|
2021-02-15 09:25:35 +00:00
|
|
|
worker:
|
|
|
|
type: 'generic_worker'
|
2021-02-18 16:19:51 +00:00
|
|
|
instanceId: "{{ matrix_synapse_workers_generic_workers_port_range_start + item }}"
|
2021-02-15 09:25:35 +00: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 09:28:39 +00:00
|
|
|
loop: "{{ range(0, matrix_synapse_workers_generic_workers_count | int) | list }}"
|
2021-02-15 09:25:35 +00:00
|
|
|
|
|
|
|
- name: Build federation sender workers
|
2022-07-18 07:39:08 +00:00
|
|
|
ansible.builtin.set_fact:
|
2021-02-15 09:25:35 +00:00
|
|
|
worker:
|
|
|
|
type: 'federation_sender'
|
2021-02-18 16:19:51 +00:00
|
|
|
instanceId: "{{ item }}"
|
2021-02-15 09:25:35 +00: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 09:28:39 +00:00
|
|
|
loop: "{{ range(0, matrix_synapse_workers_federation_sender_workers_count | int) | list }}"
|
2021-02-15 09:25:35 +00:00
|
|
|
|
|
|
|
# This type of worker can only have a count of 1, at most
|
|
|
|
- name: Build pusher workers
|
2022-07-18 07:39:08 +00:00
|
|
|
ansible.builtin.set_fact:
|
2021-02-15 09:25:35 +00:00
|
|
|
worker:
|
|
|
|
type: 'pusher'
|
2021-02-18 16:19:51 +00:00
|
|
|
instanceId: "{{ item }}"
|
2021-02-15 09:25:35 +00: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 09:28:39 +00:00
|
|
|
loop: "{{ range(0, matrix_synapse_workers_pusher_workers_count | int) | list }}"
|
2021-02-15 09:25:35 +00:00
|
|
|
|
|
|
|
# This type of worker can only have a count of 1, at most
|
|
|
|
- name: Build appservice workers
|
2022-07-18 07:39:08 +00:00
|
|
|
ansible.builtin.set_fact:
|
2021-02-15 09:25:35 +00:00
|
|
|
worker:
|
|
|
|
type: 'appservice'
|
2021-02-18 16:19:51 +00:00
|
|
|
instanceId: "{{ item }}"
|
2021-02-15 09:25:35 +00: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 09:28:39 +00:00
|
|
|
loop: "{{ range(0, matrix_synapse_workers_appservice_workers_count | int) | list }}"
|
2021-02-15 09:25:35 +00:00
|
|
|
|
|
|
|
- name: Build media_repository workers
|
2022-07-18 07:39:08 +00:00
|
|
|
ansible.builtin.set_fact:
|
2021-02-15 09:25:35 +00:00
|
|
|
worker:
|
|
|
|
type: 'media_repository'
|
2021-02-18 16:19:51 +00:00
|
|
|
instanceId: "{{ matrix_synapse_workers_media_repository_workers_port_range_start + item }}"
|
2021-02-15 09:25:35 +00: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 09:28:39 +00:00
|
|
|
loop: "{{ range(0, matrix_synapse_workers_media_repository_workers_count | int) | list }}"
|
2021-02-15 09:25:35 +00:00
|
|
|
|
2022-07-18 07:39:08 +00:00
|
|
|
- ansible.builtin.set_fact:
|
2022-07-18 08:22:05 +00:00
|
|
|
matrix_synapse_dynamic_workers_list: "{{ matrix_synapse_dynamic_workers_list | default([]) + [item.ansible_facts.worker] }}"
|
2021-02-15 09:25:35 +00:00
|
|
|
with_items: |
|
|
|
|
{{
|
|
|
|
matrix_synapse_workers_list_results_generic_workers.results
|
|
|
|
+
|
|
|
|
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
|
|
|
|
+
|
|
|
|
matrix_synapse_workers_list_results_media_repository_workers.results
|
|
|
|
}}
|
|
|
|
|
2022-07-18 07:39:08 +00:00
|
|
|
- ansible.builtin.set_fact:
|
2021-02-15 09:25:35 +00:00
|
|
|
matrix_synapse_workers_enabled_list: "{{ matrix_synapse_dynamic_workers_list }}"
|