From 56880ad220d534c6e8745eb4a61857d911ef3a4a Mon Sep 17 00:00:00 2001 From: Michael Hollister Date: Thu, 22 Jun 2023 19:32:22 -0500 Subject: [PATCH] Fixed linting errors --- .../tasks/synapse/workers/setup_install.yml | 7 +++---- .../workers/util/setup_files_for_worker.yml | 13 +++++++----- .../workers/util/worker_setup_job_cleanup.yml | 20 ++++++------------- 3 files changed, 17 insertions(+), 23 deletions(-) diff --git a/roles/custom/matrix-synapse/tasks/synapse/workers/setup_install.yml b/roles/custom/matrix-synapse/tasks/synapse/workers/setup_install.yml index 840f1886f..3aa7b3332 100644 --- a/roles/custom/matrix-synapse/tasks/synapse/workers/setup_install.yml +++ b/roles/custom/matrix-synapse/tasks/synapse/workers/setup_install.yml @@ -9,6 +9,7 @@ - ansible.builtin.set_fact: 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. - name: Ensure unnecessary worker configs are cleaned @@ -45,11 +46,9 @@ with_items: "{{ matrix_synapse_workers_enabled_list }}" loop_control: loop_var: matrix_synapse_worker_details - index_var: worker_template_creation_index - 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_workers_enabled_list }}" + with_items: "{{ matrix_synapse_worker_template_job_status_result_list }}" loop_control: - loop_var: matrix_synapse_worker_details - index_var: worker_template_job_status_index + loop_var: matrix_synapse_worker_template_job_status diff --git a/roles/custom/matrix-synapse/tasks/synapse/workers/util/setup_files_for_worker.yml b/roles/custom/matrix-synapse/tasks/synapse/workers/util/setup_files_for_worker.yml index 03bac63ed..31d8bf240 100644 --- a/roles/custom/matrix-synapse/tasks/synapse/workers/util/setup_files_for_worker.yml +++ b/roles/custom/matrix-synapse/tasks/synapse/workers/util/setup_files_for_worker.yml @@ -29,6 +29,7 @@ become: false async: 60 poll: 0 + changed_when: false - name: Ensure systemd service exists for {{ matrix_synapse_worker_systemd_service_name }} ansible.builtin.command: > @@ -64,11 +65,13 @@ become: false async: 60 poll: 0 + changed_when: false -# Create unique variable identifiers for checking job status later +# Store job status results for checking later - ansible.builtin.set_fact: - "{{ item.name }}": "{{ item.val }}" - when: item.name not in vars + matrix_synapse_worker_template_job_status_result_list: "{{ matrix_synapse_worker_template_job_status_result_list + [item] }}" with_items: - - { name: "configuration_result_{{ worker_template_creation_index }}", val: "{{ configuration_result }}" } - - { name: "service_result_{{ worker_template_creation_index }}", val: "{{ service_result }}" } + - result: + name: "{{ matrix_synapse_worker_details.name }}" + configuration: "{{ configuration_result }}" + service: "{{ service_result }}" diff --git a/roles/custom/matrix-synapse/tasks/synapse/workers/util/worker_setup_job_cleanup.yml b/roles/custom/matrix-synapse/tasks/synapse/workers/util/worker_setup_job_cleanup.yml index 2e6839472..917ae8d82 100644 --- a/roles/custom/matrix-synapse/tasks/synapse/workers/util/worker_setup_job_cleanup.yml +++ b/roles/custom/matrix-synapse/tasks/synapse/workers/util/worker_setup_job_cleanup.yml @@ -1,11 +1,9 @@ --- # Clean up Ansible controller temp files as a result of spawning async tasks -- name: Check job status for configuration file {{ matrix_synapse_worker_details.name }} - vars: - worker_configuration_result: "{{ lookup('ansible.builtin.vars', 'configuration_result_' + worker_template_job_status_index|string) }}" +- name: Check job status for configuration file {{ matrix_synapse_worker_template_job_status.result.name }} ansible.builtin.async_status: - jid: "{{ worker_configuration_result.ansible_job_id }}" + jid: "{{ matrix_synapse_worker_template_job_status.result.configuration.ansible_job_id }}" register: configuration_status until: configuration_status.finished retries: 60 @@ -13,11 +11,9 @@ delegate_to: localhost become: false -- name: Check job status for service file {{ matrix_synapse_worker_details.name }} - vars: - worker_service_result: "{{ lookup('ansible.builtin.vars', 'service_result_' + worker_template_job_status_index|string) }}" +- name: Check job status for service file {{ matrix_synapse_worker_template_job_status.result.name }} ansible.builtin.async_status: - jid: "{{ worker_service_result.ansible_job_id }}" + jid: "{{ matrix_synapse_worker_template_job_status.result.service.ansible_job_id }}" register: service_status until: service_status.finished retries: 60 @@ -26,19 +22,15 @@ become: false - name: Cleanup job result for configuration file - vars: - worker_configuration_result: "{{ lookup('ansible.builtin.vars', 'configuration_result_' + worker_template_job_status_index|string) }}" ansible.builtin.async_status: - jid: "{{ worker_configuration_result.ansible_job_id }}" + 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 - vars: - worker_service_result: "{{ lookup('ansible.builtin.vars', 'service_result_' + worker_template_job_status_index|string) }}" ansible.builtin.async_status: - jid: "{{ worker_service_result.ansible_job_id }}" + jid: "{{ matrix_synapse_worker_template_job_status.result.service.ansible_job_id }}" mode: "cleanup" delegate_to: localhost become: false