sap-linuxlab / community.sap_install

Automation for SAP - Collection of Ansible Roles for various SAP software installation
Apache License 2.0
53 stars 56 forks source link

sap_swpm: Error with argument reference in detect_variables.yml #498

Open jodonnel opened 1 year ago

jodonnel commented 1 year ago

Writing on behalf of a customer who has been working with community roles to install Suite on HANA using advanced templates mode.

In this case, detect_variables.yml references $3 in the detect software path task:

# Detect Software Path
- name: SAP SWPM - Detect Software Path
  ansible.builtin.shell: |
    set -o pipefail && cat {{ sap_swpm_tmpdir.path }}/inifile.params | grep archives.downloadBasket | awk '{ print $3 }'
  register: sap_swpm_inifile_software_path
  changed_when: false

But there appears to be no third argument passed and the download software item appears to actually be $2.

When he changes the code as follows, it corrects the problem:

# Detect Software Path
- name: SAP SWPM - Detect Software Path
  ansible.builtin.shell: |
    #set -o pipefail && cat {{ sap_swpm_tmpdir.path }}/inifile.params | grep archives.downloadBasket | awk '{ print $3 }'

 set -o pipefail && cat {{ sap_swpm_tmpdir.path }}/inifile.params | grep archives.downloadBasket | awk -F '=' '{ print $2 }'

  register: sap_swpm_inifile_software_path
  changed_when: false

Customer has moved past this issue with the above change but wanted to get it in front of the community in case others are impacted.

berndfinger commented 1 year ago

@jodonnel Can you please ask your customer to check if https://github.com/sap-linuxlab/community.sap_install/blob/5b920752aa818fcd9fe96ce740bffaa314baf99e/roles/sap_swpm/tasks/swpm/detect_variables.yml#L25 fixes the problem as well? It's already in the current main branch. That code assumes that there is a space around the "equals" (=) sign, causing the 3rd field of the output to contain the desired value. If there is no space in this line in the customer's inifile.params file, can you please ask how this file had been created, and ask to test the following alternative code: awk 'BEGIN{FS="="}!/^#/&&/archives.downloadBasket/{gsub (" ", "", $NF); print $NF}' inifile.params ?

Many thanks!