From da32e3bf1e885c24ad3d755592e5435574380198 Mon Sep 17 00:00:00 2001 From: Bernd Finger Date: Thu, 5 Sep 2024 15:13:42 +0200 Subject: [PATCH 1/2] sap_install_media_detect: Fix issue #859 Signed-off-by: Bernd Finger --- .../tasks/prepare/create_file_list_phase_2.yml | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/roles/sap_install_media_detect/tasks/prepare/create_file_list_phase_2.yml b/roles/sap_install_media_detect/tasks/prepare/create_file_list_phase_2.yml index a2391d39..03cbfa5d 100644 --- a/roles/sap_install_media_detect/tasks/prepare/create_file_list_phase_2.yml +++ b/roles/sap_install_media_detect/tasks/prepare/create_file_list_phase_2.yml @@ -27,22 +27,32 @@ - name: SAP Install Media Detect - Prepare - Iterate over files and determine file type, including command for handling RAR files ansible.builtin.command: "{{ __sap_install_media_detect_sapfile_path }} -e --lsar_file={{ __sap_install_media_detect_rar_list.split(' ')[0] }} --sapcar_file={{ __sap_install_media_detect_fact_sapcar_path }} {{ line_item }}" - register: __sap_install_media_detect_register_files_phase_2 + register: __sap_install_media_detect_register_files_phase_2_rar loop: "{{ __sap_install_media_detect_fact_find_result_phase_2 }}" loop_control: loop_var: line_item changed_when: false when: sap_install_media_detect_rar_handling +- name: SAP Install Media Detect - Prepare - Set fact from determining the file type, including RAR handling + ansible.builtin.set_fact: + __sap_install_media_detect_register_files_phase_2: "{{ __sap_install_media_detect_register_files_phase_2_rar }}" + when: sap_install_media_detect_rar_handling + - name: SAP Install Media Detect - Prepare - Iterate over files and determine file type, without command for handling RAR files ansible.builtin.command: "{{ __sap_install_media_detect_sapfile_path }} -e --sapcar_file={{ __sap_install_media_detect_fact_sapcar_path }} {{ line_item }}" - register: __sap_install_media_detect_register_files_phase_2 + register: __sap_install_media_detect_register_files_phase_2_norar loop: "{{ __sap_install_media_detect_fact_find_result_phase_2 }}" loop_control: loop_var: line_item changed_when: false when: not sap_install_media_detect_rar_handling +- name: SAP Install Media Detect - Prepare - Set fact from determining the file type, without RAR handling + ansible.builtin.set_fact: + __sap_install_media_detect_register_files_phase_2: "{{ __sap_install_media_detect_register_files_phase_2_norar }}" + when: not sap_install_media_detect_rar_handling + - name: SAP Install Media Detect - Prepare - Set fact with the results of the sapfile command ansible.builtin.set_fact: __sap_install_media_detect_fact_files_sapfile_results: "{{ __sap_install_media_detect_fact_files_sapfile_results + [__new_dict] }}" From 2a2e1859b81c8d548bb59527e9c01fbd64881e70 Mon Sep 17 00:00:00 2001 From: Bernd Finger Date: Thu, 5 Sep 2024 15:57:50 +0200 Subject: [PATCH 2/2] sap_install_media_detect: Use Jinja2 for conditionally setting the variable Signed-off-by: Bernd Finger --- .../tasks/prepare/create_file_list_phase_2.yml | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/roles/sap_install_media_detect/tasks/prepare/create_file_list_phase_2.yml b/roles/sap_install_media_detect/tasks/prepare/create_file_list_phase_2.yml index 03cbfa5d..e6b6d249 100644 --- a/roles/sap_install_media_detect/tasks/prepare/create_file_list_phase_2.yml +++ b/roles/sap_install_media_detect/tasks/prepare/create_file_list_phase_2.yml @@ -34,11 +34,6 @@ changed_when: false when: sap_install_media_detect_rar_handling -- name: SAP Install Media Detect - Prepare - Set fact from determining the file type, including RAR handling - ansible.builtin.set_fact: - __sap_install_media_detect_register_files_phase_2: "{{ __sap_install_media_detect_register_files_phase_2_rar }}" - when: sap_install_media_detect_rar_handling - - name: SAP Install Media Detect - Prepare - Iterate over files and determine file type, without command for handling RAR files ansible.builtin.command: "{{ __sap_install_media_detect_sapfile_path }} -e --sapcar_file={{ __sap_install_media_detect_fact_sapcar_path }} {{ line_item }}" register: __sap_install_media_detect_register_files_phase_2_norar @@ -48,10 +43,11 @@ changed_when: false when: not sap_install_media_detect_rar_handling -- name: SAP Install Media Detect - Prepare - Set fact from determining the file type, without RAR handling +- name: SAP Install Media Detect - Prepare - Set fact from determining the file type ansible.builtin.set_fact: - __sap_install_media_detect_register_files_phase_2: "{{ __sap_install_media_detect_register_files_phase_2_norar }}" - when: not sap_install_media_detect_rar_handling + __sap_install_media_detect_register_files_phase_2: "{{ __sap_install_media_detect_register_files_phase_2_rar + if sap_install_media_detect_rar_handling + else __sap_install_media_detect_register_files_phase_2_norar }}" - name: SAP Install Media Detect - Prepare - Set fact with the results of the sapfile command ansible.builtin.set_fact: