Skip to content

Commit

Permalink
Merge pull request sap-linuxlab#735 from berndfinger/issue-721
Browse files Browse the repository at this point in the history
sap_swpm: No longer change mode and user of files in extracted dirs
  • Loading branch information
berndfinger authored Jun 24, 2024
2 parents 76ecb94 + 2674428 commit f2e3eb0
Showing 1 changed file with 19 additions and 28 deletions.
47 changes: 19 additions & 28 deletions roles/sap_swpm/tasks/swpm/prepare_software.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,31 +22,9 @@
file_type: directory
register: __sap_swpm_register_find_result_directories

- name: SAP SWPM Pre Install - Find non-SAPCAR files
ansible.builtin.find:
path: "{{ sap_swpm_software_path }}"
file_type: file
recurse: true
excludes: "SAPCAR*EXE"
register: __sap_swpm_register_find_result_files_non_sapcar

- name: SAP SWPM Pre Install - Create list of absolute directory names from the find result
ansible.builtin.set_fact:
__sap_swpm_fact_directories: "{{ __sap_swpm_fact_directories | d([]) + [line_item.path] }}"
loop: "{{ __sap_swpm_register_find_result_directories.files }}"
loop_control:
loop_var: line_item
label: "{{ line_item.path }}"
when: __sap_swpm_register_find_result_directories is defined

- name: SAP SWPM Pre Install - Create list of absolute file names for non-SAPCAR files from the find result
- name: SAP SWPM Pre Install - Create list of directories
ansible.builtin.set_fact:
__sap_swpm_fact_files_non_sapcar: "{{ __sap_swpm_fact_files_non_sapcar | d([]) + [line_item.path] }}"
loop: "{{ __sap_swpm_register_find_result_files_non_sapcar.files }}"
loop_control:
loop_var: line_item
label: "{{ line_item.path }}"
when: __sap_swpm_register_find_result_files_non_sapcar is defined
__sap_swpm_fact_directories: "{{ __sap_swpm_register_find_result_directories.files | map(attribute='path') | reject('contains', 'extracted') }}"

- name: SAP SWPM Pre Install - Ensure correct permissions and ownership of all directories
ansible.builtin.file:
Expand All @@ -62,19 +40,32 @@
- __sap_swpm_fact_directories is defined
- __sap_swpm_register_find_result_directories is defined

- name: SAP SWPM Pre Install - Create argument list for chown and chmod of non-SAPCAR*EXE files
- name: SAP SWPM Pre Install - Find non-SAPCAR files
ansible.builtin.find:
path: "{{ sap_swpm_software_path }}"
file_type: file
recurse: true
excludes: "SAPCAR*EXE"
register: __sap_swpm_register_find_result_files_non_sapcar

- name: SAP SWPM Pre Install - Create list of files
ansible.builtin.set_fact:
__sap_swpm_fact_files_non_sapcar_chown_arg_list: "{{ __sap_swpm_fact_files_non_sapcar | map('quote') | join(' ') }}"
__sap_swpm_fact_files_non_sapcar: "{{ __sap_swpm_register_find_result_files_non_sapcar.files | map(attribute='path') | reject('contains', 'extracted/') }}"
when: __sap_swpm_register_find_result_files_non_sapcar is defined

# Reasons for noqa:
# - command-instead-of-module: Shorter execution time compared to looping over a list when using the file module
# - no-changed-when: Not worth checking permissions and ownership before this task and comparing afterwards
- name: SAP SWPM Pre Install - Ensure correct permissions and ownership of all non-SAPCAR files # noqa command-instead-of-module no-changed-when
ansible.builtin.shell: >
chown {{ sap_swpm_files_non_sapcar_owner }}:{{ sap_swpm_files_non_sapcar_group }} \
{{ __sap_swpm_fact_files_non_sapcar_chown_arg_list }} &&
{{ line_item | join(' ') }} &&
chmod {{ sap_swpm_files_non_sapcar_mode }} \
{{ __sap_swpm_fact_files_non_sapcar_chown_arg_list }}
{{ line_item | join(' ') }}
loop: "{{ __sap_swpm_fact_files_non_sapcar | batch(100) }}"
loop_control:
loop_var: line_item
label: "Batch {{ (__sap_swpm_fact_files_non_sapcar.index(line_item[0]) // 100) + 1 }}, first item: {{ line_item[0] }}"
when:
- __sap_swpm_fact_files_non_sapcar is defined
- __sap_swpm_register_find_result_files_non_sapcar is defined
Expand Down

0 comments on commit f2e3eb0

Please sign in to comment.