mirror of
https://github.com/famedly/ansible-collection-matrix
synced 2024-12-13 12:42:29 +00:00
216 lines
8.5 KiB
YAML
216 lines
8.5 KiB
YAML
---
|
|
|
|
# Client API config (multiple instances)
|
|
- name: Collect client API worker config
|
|
set_fact:
|
|
worker_client_info: "{{ worker_client_info|default([]) + [ worker_config ] }}"
|
|
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 }}"
|
|
worker_labels:
|
|
labels: "{{ matrix_synapse_worker_labels_base }}"
|
|
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 ]
|
|
worker_config: "{{ worker | from_yaml | combine( worker_labels ) }}"
|
|
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:
|
|
worker_fed_in_info: "{{ worker_fed_in_info|default([]) + [ worker_config ] }}"
|
|
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 }}"
|
|
worker_labels:
|
|
labels: "{{ matrix_synapse_worker_labels_base }}"
|
|
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 ]
|
|
worker_config: "{{ worker | from_yaml | combine( worker_labels ) }}"
|
|
loop: "{{ range(1, matrix_synapse_workers_federation_in + 1) | list }}"
|
|
|
|
# Federation sender config (multiple instances)
|
|
- name: Collect federation sender worker config (outbound)
|
|
set_fact:
|
|
worker_fed_out_info: "{{ worker_fed_out_info|default([]) + [ worker_config ] }}"
|
|
vars:
|
|
name: "worker_fed_out_{{ item }}"
|
|
app: "synapse.app.generic_worker"
|
|
config_file: "{{ matrix_synapse_base_path }}/{{ name }}.yaml"
|
|
worker_labels:
|
|
labels: "{{ matrix_synapse_worker_labels_base }}"
|
|
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: []
|
|
worker_config: "{{ worker | from_yaml | combine( worker_labels ) }}"
|
|
loop: "{{ range(1, matrix_synapse_workers_federation_out + 1) | list }}"
|
|
|
|
# Media workers config (multiple instances)
|
|
- name: Collect media worker config
|
|
set_fact:
|
|
worker_media_info: "{{ worker_media_info|default([]) + [ worker_config ] }}"
|
|
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 }}"
|
|
worker_labels:
|
|
labels: "{{ matrix_synapse_worker_labels_base }}"
|
|
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 ]
|
|
worker_config: "{{ worker | from_yaml | combine( worker_labels ) }}"
|
|
loop: "{{ range(1, matrix_synapse_workers_media + 1) | list }}"
|
|
|
|
# Pusher worker config (single instance)
|
|
- name: Collect pusher worker config
|
|
set_fact:
|
|
worker_pusher_info: "{{ [ worker_config ] }}"
|
|
vars:
|
|
name: "worker_pusher"
|
|
app: "synapse.app.generic_worker"
|
|
config_file: "{{ matrix_synapse_base_path }}/{{ name }}.yaml"
|
|
worker_labels:
|
|
labels: "{{ matrix_synapse_worker_labels_base }}"
|
|
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: []
|
|
worker_config: "{{ worker | from_yaml | combine( worker_labels ) }}"
|
|
when: matrix_synapse_worker_push
|
|
|
|
# Appservice worker config (single instance)
|
|
- name: Collect appservice worker config
|
|
set_fact:
|
|
worker_appservice_info: "{{ [ worker_config ] }}"
|
|
vars:
|
|
name: "worker_appservice"
|
|
app: "synapse.app.generic_worker"
|
|
config_file: "{{ matrix_synapse_base_path }}/{{ name }}.yaml"
|
|
worker_labels:
|
|
labels: "{{ matrix_synapse_worker_labels_base }}"
|
|
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: []
|
|
worker_config: "{{ worker | from_yaml | combine( worker_labels ) }}"
|
|
when: matrix_synapse_worker_appservice
|
|
|
|
# Userdirectory worker config (single instance)
|
|
- name: Collect user directory worker config
|
|
set_fact:
|
|
worker_user_dir_info: "{{ [ worker_config ] }}"
|
|
vars:
|
|
name: "worker_user_dir"
|
|
app: "synapse.app.generic_worker"
|
|
config_file: "{{ matrix_synapse_base_path }}/{{ name }}.yaml"
|
|
port: "{{ matrix_synapse_worker_listener_base_port|int + 300 }}"
|
|
worker_labels:
|
|
labels: "{{ matrix_synapse_worker_labels_base }}"
|
|
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 ]
|
|
worker_config: "{{ worker | from_yaml | combine( worker_labels ) }}"
|
|
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:
|
|
{{ (item.listeners + (matrix_synapse_worker_metrics_listener if matrix_synapse_worker_metrics_enabled else [])) | to_nice_yaml }}
|
|
{% endif %}
|
|
dest: "{{ item.config_file }}"
|
|
owner: synapse
|
|
group: synapse
|
|
mode: 0640
|
|
loop: "{{ matrix_synapse_workers }}"
|