2020-04-10 23:44:53 +02:00
|
|
|
---
|
|
|
|
|
2020-10-28 07:13:19 +01:00
|
|
|
- name: Load list of available worker apps and endpoints
|
|
|
|
include_vars: "{{ role_path }}/vars/workers.yml"
|
|
|
|
|
2020-04-10 23:44:53 +02:00
|
|
|
- name: Ensure synapse worker base service file installed
|
|
|
|
template:
|
|
|
|
src: "{{ role_path }}/templates/synapse/systemd/matrix-synapse-worker@.service.j2"
|
|
|
|
dest: "{{ matrix_systemd_path }}/matrix-synapse-worker@.service"
|
|
|
|
mode: 0644
|
|
|
|
register: matrix_synapse_worker_systemd_service_result
|
|
|
|
|
2020-10-23 20:49:53 +02:00
|
|
|
- name: Ensure previous worker service symlinks are cleaned
|
2020-04-10 23:44:53 +02:00
|
|
|
file:
|
|
|
|
path: "{{ item.root + '/' + item.path }}"
|
|
|
|
state: absent
|
|
|
|
when:
|
|
|
|
- item.state == 'link'
|
2020-04-19 10:16:01 +02:00
|
|
|
- item.path is match('matrix-synapse-worker@.*\\.service')
|
2020-04-10 23:44:53 +02:00
|
|
|
with_filetree:
|
|
|
|
- "{{ matrix_systemd_path }}/matrix-synapse.service.wants"
|
|
|
|
|
|
|
|
- name: Ensure systemd reloaded the worker service unit
|
|
|
|
service:
|
|
|
|
daemon_reload: yes
|
|
|
|
|
|
|
|
- name: Ensure individual worker service symlinks exist
|
|
|
|
service:
|
2020-10-28 07:13:19 +01:00
|
|
|
name: "matrix-synapse-worker@{{ item.type }}:{{ item.port }}.service"
|
2020-04-10 23:44:53 +02:00
|
|
|
enabled: true
|
|
|
|
with_items: "{{ matrix_synapse_workers_enabled_list }}"
|
|
|
|
|
2020-12-01 22:20:27 +01:00
|
|
|
- name: Find worker configs to be cleaned
|
|
|
|
find:
|
|
|
|
path: "{{ matrix_synapse_config_dir_path }}"
|
|
|
|
patterns: "worker.*.yaml"
|
|
|
|
use_regex: true
|
|
|
|
register: worker_config_files
|
|
|
|
|
2020-10-23 20:49:53 +02:00
|
|
|
- name: Ensure previous worker configs are cleaned
|
|
|
|
file:
|
2020-12-01 22:20:27 +01:00
|
|
|
path: "{{ item.path }}"
|
2020-10-23 20:49:53 +02:00
|
|
|
state: absent
|
2020-12-01 22:20:27 +01:00
|
|
|
with_items: "{{ worker_config_files.files }}"
|
2020-10-23 20:49:53 +02:00
|
|
|
|
2020-04-10 23:44:53 +02:00
|
|
|
- name: Ensure creation of specific worker configs
|
|
|
|
template:
|
|
|
|
src: "{{ role_path }}/templates/synapse/worker.yaml.j2"
|
2020-10-28 07:13:19 +01:00
|
|
|
dest: "{{ matrix_synapse_config_dir_path }}/worker.{{ item.type }}:{{ item.port }}.yaml"
|
2020-04-10 23:44:53 +02:00
|
|
|
with_list: "{{ matrix_synapse_workers_enabled_list }}"
|
|
|
|
|
|
|
|
- name: Add workers to synapse.wants list
|
|
|
|
set_fact:
|
|
|
|
matrix_synapse_systemd_wanted_services_list: >
|
|
|
|
{{ matrix_synapse_systemd_wanted_services_list +
|
2020-10-28 07:13:19 +01:00
|
|
|
['matrix-synapse-worker@' + item.type + ':' + item.port|string + '.service'] }}
|
2020-04-10 23:44:53 +02:00
|
|
|
with_items: "{{ matrix_synapse_workers_enabled_list }}"
|
2020-10-22 20:53:41 +02:00
|
|
|
|
|
|
|
- name: Ensure matrix-synapse-worker-write-pid script is created
|
|
|
|
copy:
|
|
|
|
src: "{{ role_path }}/files/usr-local-bin/matrix-synapse-worker-write-pid"
|
|
|
|
dest: "{{ matrix_local_bin_path }}/matrix-synapse-worker-write-pid"
|
|
|
|
mode: 0750
|
2020-10-23 20:49:53 +02:00
|
|
|
|
|
|
|
- name: Ensure jq is installed (Archlinux)
|
|
|
|
pacman:
|
|
|
|
name:
|
|
|
|
- jq
|
|
|
|
state: present
|
|
|
|
when: (ansible_distribution == 'Archlinux')
|
|
|
|
|
|
|
|
- name: Ensure jq is installed (CentOS)
|
|
|
|
yum:
|
|
|
|
name:
|
|
|
|
- jq
|
|
|
|
state: present
|
|
|
|
when: (ansible_distribution == 'CentOS')
|
|
|
|
|
|
|
|
- name: Ensure jq is installed (Debian)
|
|
|
|
apt:
|
|
|
|
name:
|
|
|
|
- jq
|
|
|
|
state: present
|
|
|
|
when: (ansible_os_family == 'Debian')
|