community.sap_install icon indicating copy to clipboard operation
community.sap_install copied to clipboard

sap_swpm: Advanced Mode not working

Open rhmk opened this issue 3 years ago • 5 comments

  • name: SAP SWPM - Detect Product ID shell: | sed -n '3p' {{ sap_swpm_tmpdir.path }}/inifile.params | awk 'NF{print $(NF-1)}' | tr -d ' register: sap_swpm_inifile_product_id_detect

This snippet destroys the product ID reliably in detect_variables.yml

rhmk avatar Mar 22 '22 02:03 rhmk

When using the inifile like shown here, the result is as expected.

berndfinger avatar Dec 21 '22 18:12 berndfinger

This one should solve the problem: # awk 'BEGIN{IGNORECASE = 1}{gsub ("#", "")}/product id/{print $NF}' {{ sap_swpm_tmpdir.path }}/inifile.params | tr -d \' It prints the product ID when using the inifile created by the sap_swpm role and also when using the inifile which has the product ID in the third line, like here or here.

berndfinger avatar Dec 21 '22 18:12 berndfinger

From my point of view this is not a coding issue, but a documentation issue. When using advanced mode and creating an artificial config file the productid has to be in the lust but 1 field in the 3rd line (the same place where SAP put it)

rhmk avatar Dec 22 '22 13:12 rhmk

I suggest we modify the file template/configfile.j2 to get a header similar to what sapinst creates.

berndfinger avatar Dec 22 '22 14:12 berndfinger

An inifile.params does not require the Product ID to be displayed in the file, just best practice to do so. The 'Advanced mode' just loops over Dictionary Keys and outputs to file, nothing fancy, and it does NOT put a first line commented-out which the 'Default mode' does.

It is probably best to add one extra Ansible Task to create STYLISTIC only parity between the 'Default' and 'Advanced' modes.

I ran an installation with sap_swpm using 'Advanced mode', with the following variables and everything worked as expected. This is likley due to variable precedence for sap_swpm_product_catalog_id as it is defined in the sample before the detect_variables.yml file is included/executed.

The workflow probably needs a brief re-visit, as detect_variables.yml is probably unnecessary for anything except the 'Inifile Reuse mode', and we can add a few when/if statements to only run the Ansible Tasks if the variable for the SAP SWPM Product ID is not already defined?


In addition, while investigating this, documentation should be increased for Advanced mode (by definition it is for Advanced users who are familiar with SAP SWPM) to include the following note from the YML file itself and a new notice that was a mistake in the sample files I just used:

  • NOTE: Any zero-proceeding values in Dictionary Keys for instance numbers must be string using '01' single quote, otherwise Ansible will convert to integer 1 and SAP SWPM will crash
  • NOTE: Any true/false boolean values in Dictionary Keys for any SAP SWPM parameter must be string using 'true' / 'false', otherwise Ansible will convert to True / False and SAP SWPM will crash

Sample used for testing sap_swpm Ansible Role using 'Advanced' mode

---

- name: Ansible Playbook execution for SAP S/4HANA installation from source media
  hosts: all
  become: true

# Use include_role inside Task block, instead of using roles declaration or Task block with import_roles.
# This ensures Ansible Roles, and the tasks within, will be parsed in sequence instead of parsing at Playbook initialisation
  tasks:

    - name: Execute Ansible Role sap_swpm with SAP S/4HANA One Host installation from source media
      include_role:
        name: { role: community.sap_install.sap_swpm }

  vars:

    # sap_swpm Ansible Role mode
    sap_swpm_ansible_role_mode: advanced

    # Product ID for New Installation
    sap_swpm_product_catalog_id: NW_ABAP_OneHost:S4HANA2022.CORE.HDB.ABAP

    sap_swpm_inifile_custom_values_dictionary:
      archives.downloadBasket: /software
      HDB_Software_Dialogs.useMediaCD: 'false'
      NW_GetMasterPassword.masterPwd: NewPass$321
      nwUsers.sidadmPassword: NewPass$321
      NW_DDIC_Password.ddic000Password: NewPass$321
      DiagnosticsAgent.dasidAdmPassword: NewPass$321
      hostAgent.sapAdmPassword: NewPass$321
      HDB_Schema_Check_Dialogs.schemaPassword: NewPass$321
      storageBasedCopy.hdb.systemPassword: NewPass$321
      HDB_Schema_Check_Dialogs.schemaName: SAPHANADB
      HDB_Schema_Check_Dialogs.validateSchemaName: 'false'
      NW_HDB_getDBInfo.dbhost: "{{ ansible_hostname }}"
      NW_HDB_getDBInfo.dbsid: H01
      NW_HDB_getDBInfo.systemid: H01
      NW_HDB_getDBInfo.instanceNumber: '10'
      NW_HDB_getDBInfo.systemDbPassword: NewPass$321
      NW_HDB_getDBInfo.systemPassword: NewPass$321
      NW_HDB_DB.abapSchemaName: SAPHANADB
      NW_HDB_DB.abapSchemaPassword: NewPass$321
      NW_Recovery_Install_HDB.extractLocation: /usr/sap/H01/HDB10/backup/data/DB_HDB
      NW_Recovery_Install_HDB.extractParallelJobs: 23
      NW_Recovery_Install_HDB.sidAdmName: h01adm
      NW_Recovery_Install_HDB.sidAdmPassword: NewPass$321
      NW_getFQDN.FQDN: poc.cloud
      NW_getFQDN.setFQDN: 'true'
      NW_getLoadType.loadType: SAP
      NW_readProfileDir.profileDir: /sapmnt/S01/profile
      NW_GetSidNoProfiles.sid: S01
      NW_CI_Instance.ascsVirtualHostname: "{{ ansible_hostname }}"
      NW_CI_Instance.ascsInstanceNumber: '01'
      NW_SCS_Instance.ascsInstanceNumber: '01'
      NW_CI_Instance.ciInstanceNumber: '00'
      NW_CI_Instance.ciMSPort: 3601
      NW_checkMsgServer.abapMSPort: 3601

    # Software
    sap_swpm_sapcar_path: /software
    sap_swpm_swpm_path: /software
    sap_swpm_software_path: /software

    # HDB Instance Parameters
    # For dual host installation, change the db_host to appropriate value
    sap_swpm_update_etchosts: false

sean-freeman avatar Dec 26 '22 13:12 sean-freeman

The latest version of sap_swpm does not longer implement different modes, so this issue should no longer be relevant.

berndfinger avatar Feb 17 '25 10:02 berndfinger