2020-04-10 21:44:53 +00:00
|
|
|
---
|
|
|
|
|
2021-01-25 13:20:37 +00:00
|
|
|
- name: Determine current worker configs
|
2022-07-18 08:22:05 +00:00
|
|
|
ansible.builtin.find:
|
2020-12-01 21:20:27 +00:00
|
|
|
path: "{{ matrix_synapse_config_dir_path }}"
|
|
|
|
patterns: "worker.*.yaml"
|
|
|
|
use_regex: true
|
2021-01-25 10:14:46 +00:00
|
|
|
register: matrix_synapse_workers_current_config_files
|
2020-12-01 21:20:27 +00:00
|
|
|
|
2022-11-24 15:39:34 +00:00
|
|
|
- ansible.builtin.set_fact:
|
2022-11-24 15:06:31 +00:00
|
|
|
matrix_synapse_enabled_worker_names: "{{ matrix_synapse_workers_enabled_list | map(attribute='name') }}"
|
|
|
|
|
2021-01-25 13:20:37 +00:00
|
|
|
# This also deletes some things which we need. They will be recreated below.
|
2022-11-24 15:06:31 +00:00
|
|
|
- name: Ensure unnecessary worker configs are cleaned
|
2022-07-18 07:39:08 +00:00
|
|
|
ansible.builtin.file:
|
2020-12-01 21:20:27 +00:00
|
|
|
path: "{{ item.path }}"
|
2020-10-23 18:49:53 +00:00
|
|
|
state: absent
|
2021-01-25 10:14:46 +00:00
|
|
|
with_items: "{{ matrix_synapse_workers_current_config_files.files }}"
|
2022-11-24 15:06:31 +00:00
|
|
|
when: "not ansible_check_mode and (item.path | basename | replace ('worker.', '') | replace('.yaml', '')) not in matrix_synapse_enabled_worker_names"
|
2020-10-23 18:49:53 +00:00
|
|
|
|
2021-01-25 13:20:37 +00:00
|
|
|
- name: Determine current worker systemd services
|
2022-07-18 08:22:05 +00:00
|
|
|
ansible.builtin.find:
|
2022-11-04 14:38:38 +00:00
|
|
|
path: "{{ devture_systemd_docker_base_systemd_path }}"
|
2021-01-25 10:14:46 +00:00
|
|
|
patterns: "matrix-synapse-worker.*.service"
|
|
|
|
use_regex: true
|
|
|
|
register: matrix_synapse_workers_current_systemd_services
|
2020-10-23 18:49:53 +00:00
|
|
|
|
2021-01-25 13:20:37 +00:00
|
|
|
- name: Ensure unnecessary worker systemd services are stopped and disabled
|
2022-07-18 07:39:08 +00:00
|
|
|
ansible.builtin.service:
|
2022-07-18 08:22:05 +00:00
|
|
|
name: "{{ item.path | basename }}"
|
2021-01-25 13:20:37 +00:00
|
|
|
state: stopped
|
|
|
|
enabled: false
|
|
|
|
with_items: "{{ matrix_synapse_workers_current_systemd_services.files }}"
|
2022-11-24 15:06:31 +00:00
|
|
|
when: "not ansible_check_mode and (item.path | basename | replace('.service', '')) not in matrix_synapse_enabled_worker_names"
|
2021-01-25 13:20:37 +00:00
|
|
|
|
|
|
|
- name: Ensure unnecessary worker systemd services are cleaned
|
2022-07-18 07:39:08 +00:00
|
|
|
ansible.builtin.file:
|
2021-01-25 10:14:46 +00:00
|
|
|
path: "{{ item.path }}"
|
|
|
|
state: absent
|
|
|
|
with_items: "{{ matrix_synapse_workers_current_systemd_services.files }}"
|
2022-11-24 15:06:31 +00:00
|
|
|
when: "not ansible_check_mode and (item.path | basename | replace('.service', '')) not in matrix_synapse_enabled_worker_names"
|
2020-10-23 18:49:53 +00:00
|
|
|
|
2024-01-12 10:15:40 +00:00
|
|
|
- name: Determine current worker label files
|
|
|
|
ansible.builtin.find:
|
|
|
|
path: "{{ matrix_synapse_base_path }}"
|
|
|
|
patterns: "worker.*.labels"
|
|
|
|
use_regex: true
|
|
|
|
register: matrix_synapse_workers_current_label_files
|
|
|
|
|
|
|
|
- name: Ensure unnecessary worker labels are cleaned
|
|
|
|
ansible.builtin.file:
|
|
|
|
path: "{{ item.path }}"
|
|
|
|
state: absent
|
|
|
|
with_items: "{{ matrix_synapse_workers_current_label_files.files }}"
|
|
|
|
when: "not ansible_check_mode and (item.path | basename | replace ('worker.', '') | replace('.labels', '')) not in matrix_synapse_enabled_worker_names"
|
|
|
|
|
2021-01-25 10:14:46 +00:00
|
|
|
- name: Ensure creation of worker systemd service files and configuration files
|
2022-07-18 08:22:05 +00:00
|
|
|
ansible.builtin.include_tasks: "{{ role_path }}/tasks/synapse/workers/util/setup_files_for_worker.yml"
|
2021-01-25 10:14:46 +00:00
|
|
|
with_items: "{{ matrix_synapse_workers_enabled_list }}"
|
|
|
|
loop_control:
|
|
|
|
loop_var: matrix_synapse_worker_details
|