2020-10-02 07:49:51 +00:00
|
|
|
---
|
|
|
|
|
|
|
|
# Client API config (multiple instances)
|
|
|
|
- name: Collect client API worker config
|
|
|
|
set_fact:
|
2021-04-30 06:13:09 +00:00
|
|
|
worker_client_info: "{{ worker_client_info|default([]) + [ worker_config ] }}"
|
2020-10-02 07:49:51 +00:00
|
|
|
vars:
|
|
|
|
name: "worker_client_{{ item }}"
|
|
|
|
app: "synapse.app.generic_worker"
|
|
|
|
config_file: "{{ matrix_synapse_base_path }}/{{ name }}.yaml"
|
|
|
|
port: "{{ (matrix_synapse_worker_listener_base_port|int + item|int)|int }}"
|
2021-04-30 06:13:09 +00:00
|
|
|
worker_labels:
|
|
|
|
labels: "{{ matrix_synapse_worker_labels_base }}"
|
2020-10-02 07:49:51 +00:00
|
|
|
worker: |
|
|
|
|
name: "{{ name }}"
|
|
|
|
app: "{{ app }}"
|
|
|
|
port: "{{ port }}"
|
|
|
|
config_file: "{{ config_file }}"
|
|
|
|
service_name: "matrix-{{ name }}.service"
|
|
|
|
container_name: "{{ matrix_synapse_container_name }}_{{ name }}"
|
|
|
|
container_command: "-m {{ app }} -c {{ matrix_synapse_base_path }}/homeserver.yaml -c {{ config_file }}"
|
|
|
|
extra_volumes:
|
|
|
|
- "{{ config_file }}:{{ config_file }}:z"
|
|
|
|
ports:
|
|
|
|
- "{{ matrix_synapse_worker_listener_bind_base_ip }}:{{ port }}:{{ port }}"
|
|
|
|
listeners:
|
|
|
|
- type: http
|
|
|
|
port: {{ port }}
|
|
|
|
resources:
|
|
|
|
- names: [ client ]
|
2021-04-30 06:13:09 +00:00
|
|
|
worker_config: "{{ worker | from_yaml | combine( worker_labels ) }}"
|
2020-10-02 07:49:51 +00:00
|
|
|
loop: "{{ range(1, matrix_synapse_workers_client + 1) | list }}"
|
|
|
|
|
|
|
|
# Federation API (inbound) config (multiple instances, federation listener)
|
|
|
|
- name: Collect federation API worker config (inbound)
|
|
|
|
set_fact:
|
2021-04-30 06:13:09 +00:00
|
|
|
worker_fed_in_info: "{{ worker_fed_in_info|default([]) + [ worker_config ] }}"
|
2020-10-02 07:49:51 +00:00
|
|
|
vars:
|
|
|
|
name: "worker_fed_in_{{ item }}"
|
|
|
|
app: "synapse.app.generic_worker"
|
|
|
|
config_file: "{{ matrix_synapse_base_path }}/{{ name }}.yaml"
|
|
|
|
port: "{{ matrix_synapse_worker_listener_base_port|int + 100 + item|int }}"
|
2021-04-30 06:13:09 +00:00
|
|
|
worker_labels:
|
|
|
|
labels: "{{ matrix_synapse_worker_labels_base }}"
|
2020-10-02 07:49:51 +00:00
|
|
|
worker: |
|
|
|
|
name: "{{ name }}"
|
|
|
|
app: "{{ app }}"
|
|
|
|
port: "{{ port }}"
|
|
|
|
config_file: "{{ config_file }}"
|
|
|
|
service_name: "matrix-{{ name }}.service"
|
|
|
|
container_name: "{{ matrix_synapse_container_name }}_{{ name }}"
|
|
|
|
container_command: "-m {{ app }} -c {{ matrix_synapse_base_path }}/homeserver.yaml -c {{ config_file }}"
|
|
|
|
extra_volumes:
|
|
|
|
- "{{ config_file }}:{{ config_file }}:z"
|
|
|
|
ports:
|
|
|
|
- "{{ matrix_synapse_worker_listener_bind_base_ip }}:{{ port }}:{{ port }}"
|
|
|
|
listeners:
|
|
|
|
- type: http
|
|
|
|
port: {{ port|int }}
|
|
|
|
resources:
|
|
|
|
- names: [ federation ]
|
2021-04-30 06:13:09 +00:00
|
|
|
worker_config: "{{ worker | from_yaml | combine( worker_labels ) }}"
|
2020-10-02 07:49:51 +00:00
|
|
|
loop: "{{ range(1, matrix_synapse_workers_federation_in + 1) | list }}"
|
|
|
|
|
|
|
|
# Federation sender config (multiple instances)
|
|
|
|
- name: Collect federation sender worker config (outbound)
|
|
|
|
set_fact:
|
2021-04-30 06:13:09 +00:00
|
|
|
worker_fed_out_info: "{{ worker_fed_out_info|default([]) + [ worker_config ] }}"
|
2020-10-02 07:49:51 +00:00
|
|
|
vars:
|
|
|
|
name: "worker_fed_out_{{ item }}"
|
2023-05-25 12:52:02 +00:00
|
|
|
app: "synapse.app.generic_worker"
|
2020-10-02 07:49:51 +00:00
|
|
|
config_file: "{{ matrix_synapse_base_path }}/{{ name }}.yaml"
|
2021-04-30 06:13:09 +00:00
|
|
|
worker_labels:
|
|
|
|
labels: "{{ matrix_synapse_worker_labels_base }}"
|
2020-10-02 07:49:51 +00:00
|
|
|
worker: |
|
|
|
|
name: "{{ name }}"
|
|
|
|
app: "{{ app }}"
|
|
|
|
config_file: "{{ config_file }}"
|
|
|
|
service_name: "matrix-{{ name }}.service"
|
|
|
|
container_name: "{{ matrix_synapse_container_name }}_{{ name }}"
|
|
|
|
container_command: "-m {{ app }} -c {{ matrix_synapse_base_path }}/homeserver.yaml -c {{ config_file }}"
|
|
|
|
extra_volumes:
|
|
|
|
- "{{ config_file }}:{{ config_file }}:z"
|
|
|
|
ports: []
|
|
|
|
listeners: []
|
2021-04-30 06:13:09 +00:00
|
|
|
worker_config: "{{ worker | from_yaml | combine( worker_labels ) }}"
|
2020-10-02 07:49:51 +00:00
|
|
|
loop: "{{ range(1, matrix_synapse_workers_federation_out + 1) | list }}"
|
|
|
|
|
|
|
|
# Media workers config (multiple instances)
|
|
|
|
- name: Collect media worker config
|
|
|
|
set_fact:
|
2021-04-30 06:13:09 +00:00
|
|
|
worker_media_info: "{{ worker_media_info|default([]) + [ worker_config ] }}"
|
2020-10-02 07:49:51 +00:00
|
|
|
vars:
|
|
|
|
name: "worker_media_{{ item }}"
|
|
|
|
app: "synapse.app.media_repository"
|
|
|
|
config_file: "{{ matrix_synapse_base_path }}/{{ name }}.yaml"
|
|
|
|
port: "{{ matrix_synapse_worker_listener_base_port|int + 200 + item|int }}"
|
2021-04-30 06:13:09 +00:00
|
|
|
worker_labels:
|
|
|
|
labels: "{{ matrix_synapse_worker_labels_base }}"
|
2020-10-02 07:49:51 +00:00
|
|
|
worker: |
|
|
|
|
name: "{{ name }}"
|
|
|
|
app: "{{ app }}"
|
|
|
|
port: "{{ port }}"
|
|
|
|
config_file: "{{ config_file }}"
|
|
|
|
service_name: "matrix-{{ name }}.service"
|
|
|
|
container_name: "{{ matrix_synapse_container_name }}_{{ name }}"
|
|
|
|
container_command: "-m {{ app }} -c {{ matrix_synapse_base_path }}/homeserver.yaml -c {{ config_file }}"
|
|
|
|
extra_volumes:
|
|
|
|
- "{{ config_file }}:{{ config_file }}:z"
|
|
|
|
ports:
|
|
|
|
- "{{ matrix_synapse_worker_listener_bind_base_ip }}:{{ port }}:{{ port }}"
|
|
|
|
listeners:
|
|
|
|
- type: http
|
|
|
|
port: {{ port|int }}
|
|
|
|
resources:
|
|
|
|
- names: [ media ]
|
2021-04-30 06:13:09 +00:00
|
|
|
worker_config: "{{ worker | from_yaml | combine( worker_labels ) }}"
|
2020-10-02 07:49:51 +00:00
|
|
|
loop: "{{ range(1, matrix_synapse_workers_media + 1) | list }}"
|
|
|
|
|
|
|
|
# Pusher worker config (single instance)
|
|
|
|
- name: Collect pusher worker config
|
|
|
|
set_fact:
|
2021-04-30 06:13:09 +00:00
|
|
|
worker_pusher_info: "{{ [ worker_config ] }}"
|
2020-10-02 07:49:51 +00:00
|
|
|
vars:
|
|
|
|
name: "worker_pusher"
|
2023-05-25 12:40:20 +00:00
|
|
|
app: "synapse.app.generic_worker"
|
2020-10-02 07:49:51 +00:00
|
|
|
config_file: "{{ matrix_synapse_base_path }}/{{ name }}.yaml"
|
2021-04-30 06:13:09 +00:00
|
|
|
worker_labels:
|
|
|
|
labels: "{{ matrix_synapse_worker_labels_base }}"
|
2020-10-02 07:49:51 +00:00
|
|
|
worker: |
|
|
|
|
name: "{{ name }}"
|
|
|
|
app: "{{ app }}"
|
|
|
|
config_file: "{{ config_file }}"
|
|
|
|
service_name: "matrix-{{ name }}.service"
|
|
|
|
container_name: "{{ matrix_synapse_container_name }}_{{ name }}"
|
|
|
|
container_command: "-m {{ app }} -c {{ matrix_synapse_base_path }}/homeserver.yaml -c {{ config_file }}"
|
|
|
|
extra_volumes:
|
|
|
|
- "{{ config_file }}:{{ config_file }}:z"
|
|
|
|
ports: []
|
|
|
|
listeners: []
|
2021-04-30 06:13:09 +00:00
|
|
|
worker_config: "{{ worker | from_yaml | combine( worker_labels ) }}"
|
2020-10-02 07:49:51 +00:00
|
|
|
when: matrix_synapse_worker_push
|
|
|
|
|
|
|
|
# Appservice worker config (single instance)
|
|
|
|
- name: Collect appservice worker config
|
|
|
|
set_fact:
|
2021-04-30 06:13:09 +00:00
|
|
|
worker_appservice_info: "{{ [ worker_config ] }}"
|
2020-10-02 07:49:51 +00:00
|
|
|
vars:
|
|
|
|
name: "worker_appservice"
|
2023-05-25 12:46:25 +00:00
|
|
|
app: "synapse.app.generic_worker"
|
2020-10-02 07:49:51 +00:00
|
|
|
config_file: "{{ matrix_synapse_base_path }}/{{ name }}.yaml"
|
2021-04-30 06:13:09 +00:00
|
|
|
worker_labels:
|
|
|
|
labels: "{{ matrix_synapse_worker_labels_base }}"
|
2020-10-02 07:49:51 +00:00
|
|
|
worker: |
|
|
|
|
name: "{{ name }}"
|
|
|
|
app: "{{ app }}"
|
|
|
|
config_file: "{{ config_file }}"
|
|
|
|
service_name: "matrix-{{ name }}.service"
|
|
|
|
container_name: "{{ matrix_synapse_container_name }}_{{ name }}"
|
|
|
|
container_command: "-m {{ app }} -c {{ matrix_synapse_base_path }}/homeserver.yaml -c {{ config_file }}"
|
|
|
|
extra_volumes:
|
|
|
|
- "{{ config_file }}:{{ config_file }}:z"
|
|
|
|
ports: []
|
|
|
|
listeners: []
|
2021-04-30 06:13:09 +00:00
|
|
|
worker_config: "{{ worker | from_yaml | combine( worker_labels ) }}"
|
2020-10-02 07:49:51 +00:00
|
|
|
when: matrix_synapse_worker_appservice
|
|
|
|
|
|
|
|
# Userdirectory worker config (single instance)
|
|
|
|
- name: Collect user directory worker config
|
|
|
|
set_fact:
|
2021-04-30 06:13:09 +00:00
|
|
|
worker_user_dir_info: "{{ [ worker_config ] }}"
|
2020-10-02 07:49:51 +00:00
|
|
|
vars:
|
|
|
|
name: "worker_user_dir"
|
2023-05-25 12:49:06 +00:00
|
|
|
app: "synapse.app.generic_worker"
|
2020-10-02 07:49:51 +00:00
|
|
|
config_file: "{{ matrix_synapse_base_path }}/{{ name }}.yaml"
|
|
|
|
port: "{{ matrix_synapse_worker_listener_base_port|int + 300 }}"
|
2021-04-30 06:13:09 +00:00
|
|
|
worker_labels:
|
|
|
|
labels: "{{ matrix_synapse_worker_labels_base }}"
|
2020-10-02 07:49:51 +00:00
|
|
|
worker: |
|
|
|
|
name: "{{ name }}"
|
|
|
|
app: "{{ app }}"
|
|
|
|
port: "{{ port }}"
|
|
|
|
config_file: "{{ config_file }}"
|
|
|
|
service_name: "matrix-{{ name }}.service"
|
|
|
|
container_name: "{{ matrix_synapse_container_name }}_{{ name }}"
|
|
|
|
container_command: "-m {{ app }} -c {{ matrix_synapse_base_path }}/homeserver.yaml -c {{ config_file }}"
|
|
|
|
extra_volumes:
|
|
|
|
- "{{ config_file }}:{{ config_file }}:z"
|
|
|
|
ports:
|
|
|
|
- "{{ matrix_synapse_worker_listener_bind_base_ip }}:{{ port }}:{{ port }}"
|
|
|
|
listeners:
|
|
|
|
- type: http
|
|
|
|
port: {{ port }}
|
|
|
|
resources:
|
|
|
|
- names: [ client ]
|
2021-04-30 06:13:09 +00:00
|
|
|
worker_config: "{{ worker | from_yaml | combine( worker_labels ) }}"
|
2020-10-02 07:49:51 +00:00
|
|
|
when: matrix_synapse_worker_user_search
|
|
|
|
|
|
|
|
- name: Collect worker configuration
|
|
|
|
set_fact:
|
|
|
|
matrix_synapse_workers: "{{ worker_client_info|default([]) + worker_fed_in_info|default([]) + worker_fed_out_info|default([]) + worker_media_info|default([]) + worker_pusher_info|default([]) + worker_appservice_info|default([]) + worker_user_dir_info|default([]) }}"
|
|
|
|
|
|
|
|
- name: Write worker configuration files
|
|
|
|
copy:
|
|
|
|
content: |
|
|
|
|
worker_app: {{ item.app }}
|
|
|
|
worker_name: {{ item.name }}
|
|
|
|
{% if item.listeners|length > 0 or matrix_synapse_worker_metrics_enabled %}
|
|
|
|
worker_listeners:
|
2021-09-16 07:36:56 +00:00
|
|
|
{{ (item.listeners + (matrix_synapse_worker_metrics_listener if matrix_synapse_worker_metrics_enabled else [])) | to_nice_yaml }}
|
2020-10-02 07:49:51 +00:00
|
|
|
{% endif %}
|
|
|
|
dest: "{{ item.config_file }}"
|
|
|
|
owner: synapse
|
|
|
|
group: synapse
|
|
|
|
mode: 0640
|
|
|
|
loop: "{{ matrix_synapse_workers }}"
|