mirror of
https://github.com/spantaleev/matrix-docker-ansible-deploy.git
synced 2025-01-30 20:05:01 +01:00
Merge 56880ad220d534c6e8745eb4a61857d911ef3a4a into ca8c1cf2b5416924c4379d43d5c943928377747d
This commit is contained in:
commit
650b9b0406
@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
- ansible.builtin.set_fact:
|
- ansible.builtin.set_fact:
|
||||||
matrix_synapse_enabled_worker_names: "{{ matrix_synapse_workers_enabled_list | map(attribute='name') }}"
|
matrix_synapse_enabled_worker_names: "{{ matrix_synapse_workers_enabled_list | map(attribute='name') }}"
|
||||||
|
matrix_synapse_worker_template_job_status_result_list: []
|
||||||
|
|
||||||
# This also deletes some things which we need. They will be recreated below.
|
# This also deletes some things which we need. They will be recreated below.
|
||||||
- name: Ensure unnecessary worker configs are cleaned
|
- name: Ensure unnecessary worker configs are cleaned
|
||||||
@ -59,3 +60,9 @@
|
|||||||
with_items: "{{ matrix_synapse_workers_enabled_list }}"
|
with_items: "{{ matrix_synapse_workers_enabled_list }}"
|
||||||
loop_control:
|
loop_control:
|
||||||
loop_var: matrix_synapse_worker_details
|
loop_var: matrix_synapse_worker_details
|
||||||
|
|
||||||
|
- name: Check status of worker systemd service files and configuration files creation
|
||||||
|
ansible.builtin.include_tasks: "{{ role_path }}/tasks/synapse/workers/util/worker_setup_job_cleanup.yml"
|
||||||
|
with_items: "{{ matrix_synapse_worker_template_job_status_result_list }}"
|
||||||
|
loop_control:
|
||||||
|
loop_var: matrix_synapse_worker_template_job_status
|
||||||
|
@ -7,13 +7,31 @@
|
|||||||
matrix_synapse_worker_config_file_name: "worker.{{ matrix_synapse_worker_details.name }}.yaml"
|
matrix_synapse_worker_config_file_name: "worker.{{ matrix_synapse_worker_details.name }}.yaml"
|
||||||
matrix_synapse_worker_labels_file_name: "worker.{{ matrix_synapse_worker_details.name }}.labels"
|
matrix_synapse_worker_labels_file_name: "worker.{{ matrix_synapse_worker_details.name }}.labels"
|
||||||
|
|
||||||
|
# ansible.builtin.template does not support async, so instead run async commands
|
||||||
|
# that launch ad hoc template tasks on the controller.
|
||||||
- name: Ensure configuration exists for {{ matrix_synapse_worker_systemd_service_name }}
|
- name: Ensure configuration exists for {{ matrix_synapse_worker_systemd_service_name }}
|
||||||
ansible.builtin.template:
|
ansible.builtin.command: >
|
||||||
src: "{{ role_path }}/templates/synapse/worker.yaml.j2"
|
ansible matrix_servers -i inventory/hosts -m template --become
|
||||||
dest: "{{ matrix_synapse_config_dir_path }}/{{ matrix_synapse_worker_config_file_name }}"
|
-e "{
|
||||||
mode: 0644
|
'matrix_synapse_worker_details':{{ matrix_synapse_worker_details }},
|
||||||
owner: "{{ matrix_synapse_uid }}"
|
'matrix_server_fqn_matrix':'{{ matrix_server_fqn_matrix }}',
|
||||||
group: "{{ matrix_synapse_gid }}"
|
'matrix_synapse_replication_listener_enabled':'{{ matrix_synapse_replication_listener_enabled }}',
|
||||||
|
'matrix_synapse_replication_http_port':'{{ matrix_synapse_replication_http_port }}',
|
||||||
|
'matrix_synapse_metrics_enabled':'{{ matrix_synapse_metrics_enabled }}'
|
||||||
|
}"
|
||||||
|
-a "
|
||||||
|
src={{ role_path }}/templates/synapse/worker.yaml.j2
|
||||||
|
dest={{ matrix_synapse_config_dir_path }}/{{ matrix_synapse_worker_config_file_name }}
|
||||||
|
mode=0644
|
||||||
|
owner={{ matrix_synapse_uid }}
|
||||||
|
group={{ matrix_synapse_gid }}
|
||||||
|
"
|
||||||
|
register: "configuration_result"
|
||||||
|
delegate_to: localhost
|
||||||
|
become: false
|
||||||
|
async: 60
|
||||||
|
poll: 0
|
||||||
|
changed_when: false
|
||||||
|
|
||||||
- name: Ensure labels exists for {{ matrix_synapse_worker_systemd_service_name }}
|
- name: Ensure labels exists for {{ matrix_synapse_worker_systemd_service_name }}
|
||||||
ansible.builtin.template:
|
ansible.builtin.template:
|
||||||
@ -24,7 +42,46 @@
|
|||||||
group: "{{ matrix_synapse_gid }}"
|
group: "{{ matrix_synapse_gid }}"
|
||||||
|
|
||||||
- name: Ensure systemd service exists for {{ matrix_synapse_worker_systemd_service_name }}
|
- name: Ensure systemd service exists for {{ matrix_synapse_worker_systemd_service_name }}
|
||||||
ansible.builtin.template:
|
ansible.builtin.command: >
|
||||||
src: "{{ role_path }}/templates/synapse/systemd/matrix-synapse-worker.service.j2"
|
ansible matrix_servers -i inventory/hosts -m template --become
|
||||||
dest: "{{ devture_systemd_docker_base_systemd_path }}/{{ matrix_synapse_worker_systemd_service_name }}.service"
|
-e "{
|
||||||
mode: 0644
|
'matrix_synapse_worker_details':{{ matrix_synapse_worker_details }},
|
||||||
|
'matrix_synapse_worker_container_name':'{{ matrix_synapse_worker_container_name }}',
|
||||||
|
'matrix_synapse_config_dir_path':'{{ matrix_synapse_config_dir_path }}',
|
||||||
|
'matrix_synapse_worker_config_file_name':'{{ matrix_synapse_worker_config_file_name }}',
|
||||||
|
'devture_systemd_docker_base_systemd_unit_home_path':'{{ devture_systemd_docker_base_systemd_unit_home_path }}',
|
||||||
|
'devture_systemd_docker_base_host_command_sh':'{{ devture_systemd_docker_base_host_command_sh }}',
|
||||||
|
'devture_systemd_docker_base_host_command_docker':'{{ devture_systemd_docker_base_host_command_docker }}',
|
||||||
|
'matrix_host_command_sleep':'{{ matrix_host_command_sleep }}',
|
||||||
|
'matrix_synapse_uid':'{{ matrix_synapse_uid }}',
|
||||||
|
'matrix_synapse_gid':'{{ matrix_synapse_gid }}',
|
||||||
|
'matrix_synapse_tmp_directory_size_mb':'{{ matrix_synapse_tmp_directory_size_mb }}',
|
||||||
|
'matrix_synapse_container_network':'{{ matrix_synapse_container_network }}',
|
||||||
|
'matrix_synapse_workers_enabled':'{{ matrix_synapse_workers_enabled }}',
|
||||||
|
'matrix_synapse_workers_container_host_bind_address':'{{ matrix_synapse_workers_container_host_bind_address }}',
|
||||||
|
'matrix_synapse_storage_path':'{{ matrix_synapse_storage_path }}',
|
||||||
|
'matrix_synapse_container_additional_volumes':{{ matrix_synapse_container_additional_volumes }},
|
||||||
|
'matrix_synapse_container_arguments':{{ matrix_synapse_container_arguments }},
|
||||||
|
'matrix_synapse_docker_image_final':'{{ matrix_synapse_docker_image_final }}',
|
||||||
|
'matrix_synapse_container_additional_networks':{{ matrix_synapse_container_additional_networks }}
|
||||||
|
}"
|
||||||
|
-a "
|
||||||
|
src={{ role_path }}/templates/synapse/systemd/matrix-synapse-worker.service.j2
|
||||||
|
dest={{ devture_systemd_docker_base_systemd_path }}/{{ matrix_synapse_worker_systemd_service_name }}.service
|
||||||
|
mode=0644
|
||||||
|
"
|
||||||
|
register: "service_result"
|
||||||
|
delegate_to: localhost
|
||||||
|
become: false
|
||||||
|
async: 60
|
||||||
|
poll: 0
|
||||||
|
changed_when: false
|
||||||
|
|
||||||
|
# Store job status results for checking later
|
||||||
|
- ansible.builtin.set_fact:
|
||||||
|
matrix_synapse_worker_template_job_status_result_list: "{{ matrix_synapse_worker_template_job_status_result_list + [item] }}"
|
||||||
|
with_items:
|
||||||
|
- result:
|
||||||
|
name: "{{ matrix_synapse_worker_details.name }}"
|
||||||
|
configuration: "{{ configuration_result }}"
|
||||||
|
service: "{{ service_result }}"
|
||||||
|
@ -0,0 +1,36 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
# Clean up Ansible controller temp files as a result of spawning async tasks
|
||||||
|
- name: Check job status for configuration file {{ matrix_synapse_worker_template_job_status.result.name }}
|
||||||
|
ansible.builtin.async_status:
|
||||||
|
jid: "{{ matrix_synapse_worker_template_job_status.result.configuration.ansible_job_id }}"
|
||||||
|
register: configuration_status
|
||||||
|
until: configuration_status.finished
|
||||||
|
retries: 60
|
||||||
|
delay: 1
|
||||||
|
delegate_to: localhost
|
||||||
|
become: false
|
||||||
|
|
||||||
|
- name: Check job status for service file {{ matrix_synapse_worker_template_job_status.result.name }}
|
||||||
|
ansible.builtin.async_status:
|
||||||
|
jid: "{{ matrix_synapse_worker_template_job_status.result.service.ansible_job_id }}"
|
||||||
|
register: service_status
|
||||||
|
until: service_status.finished
|
||||||
|
retries: 60
|
||||||
|
delay: 1
|
||||||
|
delegate_to: localhost
|
||||||
|
become: false
|
||||||
|
|
||||||
|
- name: Cleanup job result for configuration file
|
||||||
|
ansible.builtin.async_status:
|
||||||
|
jid: "{{ matrix_synapse_worker_template_job_status.result.configuration.ansible_job_id }}"
|
||||||
|
mode: "cleanup"
|
||||||
|
delegate_to: localhost
|
||||||
|
become: false
|
||||||
|
|
||||||
|
- name: Cleanup job result for service file
|
||||||
|
ansible.builtin.async_status:
|
||||||
|
jid: "{{ matrix_synapse_worker_template_job_status.result.service.ansible_job_id }}"
|
||||||
|
mode: "cleanup"
|
||||||
|
delegate_to: localhost
|
||||||
|
become: false
|
Loading…
x
Reference in New Issue
Block a user