matrix-docker-ansible-deploy/roles/custom/matrix-synapse/tasks/synapse/workers/setup_install.yml

48 lines
2.0 KiB
YAML
Raw Normal View History

---
- name: Determine current worker configs
2022-07-18 10:22:05 +02:00
ansible.builtin.find:
path: "{{ matrix_synapse_config_dir_path }}"
patterns: "worker.*.yaml"
use_regex: true
register: matrix_synapse_workers_current_config_files
2022-11-24 16:39:34 +01:00
- ansible.builtin.set_fact:
matrix_synapse_enabled_worker_names: "{{ matrix_synapse_workers_enabled_list | map(attribute='name') }}"
# This also deletes some things which we need. They will be recreated below.
- name: Ensure unnecessary worker configs are cleaned
ansible.builtin.file:
path: "{{ item.path }}"
state: absent
with_items: "{{ matrix_synapse_workers_current_config_files.files }}"
when: "not ansible_check_mode and (item.path | basename | replace ('worker.', '') | replace('.yaml', '')) not in matrix_synapse_enabled_worker_names"
- name: Determine current worker systemd services
2022-07-18 10:22:05 +02:00
ansible.builtin.find:
path: "{{ devture_systemd_docker_base_systemd_path }}"
patterns: "matrix-synapse-worker.*.service"
use_regex: true
register: matrix_synapse_workers_current_systemd_services
- name: Ensure unnecessary worker systemd services are stopped and disabled
ansible.builtin.service:
2022-07-18 10:22:05 +02:00
name: "{{ item.path | basename }}"
state: stopped
enabled: false
with_items: "{{ matrix_synapse_workers_current_systemd_services.files }}"
when: "not ansible_check_mode and (item.path | basename | replace('.service', '')) not in matrix_synapse_enabled_worker_names"
- name: Ensure unnecessary worker systemd services are cleaned
ansible.builtin.file:
path: "{{ item.path }}"
state: absent
with_items: "{{ matrix_synapse_workers_current_systemd_services.files }}"
when: "not ansible_check_mode and (item.path | basename | replace('.service', '')) not in matrix_synapse_enabled_worker_names"
- name: Ensure creation of worker systemd service files and configuration files
2022-07-18 10:22:05 +02:00
ansible.builtin.include_tasks: "{{ role_path }}/tasks/synapse/workers/util/setup_files_for_worker.yml"
with_items: "{{ matrix_synapse_workers_enabled_list }}"
loop_control:
loop_var: matrix_synapse_worker_details