Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sap_swpm: New improved and simplified version #840

Open
wants to merge 34 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
4386599
sap_swpm: No longer use different execution modes
berndfinger Aug 2, 2024
ba5fe7c
sap_swpm: Improved section markers for inifile
berndfinger Aug 5, 2024
53fc46f
sap_swpm: Reorganize yml files, part 1
berndfinger Aug 5, 2024
4ef0900
sap_swpm: Fix task name
berndfinger Aug 6, 2024
73df286
sap_swpm: Speed up inifile generation if tag is specified
berndfinger Aug 6, 2024
e065e9f
sap_swpm: Integrate the inifile_reuse mode
berndfinger Aug 6, 2024
7eb407d
sap_swpm: Reorganize yml files, part 2
berndfinger Aug 7, 2024
a9323cd
sap_swpm: Improve variable detection
berndfinger Aug 9, 2024
f3b2381
sap_swpm: Fix typo in README.md
berndfinger Aug 12, 2024
18a7446
sap_swpm: Add certain parameter consistency checks
berndfinger Aug 15, 2024
61f1b7d
sap_swpm: Adapt README.md
berndfinger Aug 22, 2024
f7e5ef7
sap_swpm: Explain how to migrate playbooks
berndfinger Aug 22, 2024
16fd86f
sap_swpm: Fix two typos in inifile_params.j2
berndfinger Aug 22, 2024
03f372b
sap_swpm: Add missing single reverse quote
berndfinger Sep 5, 2024
f039b14
sap_swpm: Repeat PR #850 and solve ansible-lint error
berndfinger Sep 5, 2024
8ce28cf
sap_swpm: Further changes to README.md
berndfinger Sep 5, 2024
6f8e23b
Merge branch 'dev' into new-role-sap_swpm_2
berndfinger Sep 5, 2024
a7875d7
sap_swpm: Only mention the `vars:` section for redefining variables
berndfinger Sep 6, 2024
06c1739
sap_swpm: Recognize sap_swpm_templates_install_dictionary
berndfinger Sep 9, 2024
f0b8339
sap_swpm: No longer define sap_swpm_product_catalog_id...
berndfinger Sep 10, 2024
95ef236
sap_swpm: Allow undefined or empty sap_swpm_role_parameters_dict
berndfinger Sep 10, 2024
c012680
sap_swpm: Prioritize sap_swpm_templates_install_dictionary members
berndfinger Sep 19, 2024
a4ba100
sap_swpm: Adapt README.md to new standard
berndfinger Sep 27, 2024
ac4b06f
docs: Update readme and add vars section
marcelmamula Oct 3, 2024
c12fa43
sap_swpm: Use sap_maintain_etc_hosts role; use booleans
berndfinger Oct 21, 2024
54c4ed7
sap_swpm: Add support for HA virtual hostname resolution
berndfinger Oct 28, 2024
b2f7bc4
sap_swpm: remove roles/sap_swpm/requirements.yml
berndfinger Oct 31, 2024
87188fa
sap_swpm: Implement changes requested for virtual IP checks
berndfinger Nov 4, 2024
0034767
sap_swpm: Run the virtual IP checks before the swpm_prepare tasks
berndfinger Nov 4, 2024
3508e01
sap_swpm: Perform additional assertions for the install type
berndfinger Nov 4, 2024
262ca2e
sap_swpm: Do not include the installation type file for default case
berndfinger Nov 5, 2024
37fff99
sap_swpm: Skip comments in /etc/hosts check
berndfinger Nov 6, 2024
c1ec503
sap_swpm: Fix /etc/hosts ip address resolution
berndfinger Nov 6, 2024
f603471
sap_swpm: Improve the fail message for virt hostname resolution
berndfinger Nov 6, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
177 changes: 81 additions & 96 deletions roles/sap_swpm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,58 +63,66 @@ This role has been tested and working for the following SAP products
### Input Parameters

The inputs are critical for running this role
- Determines the installation type
- Incomplete parameters will result to failure
- Wrong parameters will result to failure
- Incomplete parameters will result in failure
- Wrong parameters will result in failure

Create an input file which contains all relevant installation information.
Sample input files are stored in the [inputs](/playbooks/vars) folder of this Ansible collection. Use the samples as guide for your desired installation

### Default Parameters
Sample input files are stored in the [inputs](/playbooks/vars) folder of this Ansible collection. Use the samples as guide for your desired installation.

### Default Parameters

Please check the default parameters file for more information on other parameters that can be used as an input:
- [**sap_swpm** default parameters](defaults/main.yml)

Sample Playbooks and sample parameters are shown in the Ansible Collection `/playbooks` directory.

The Ansible Collection `/playbooks` directory includes sample playbooks for using the `sap_swpm` Ansible Role in the following 'modes':
- Default
- Default Templates
- Advanced
- Advanced Templates
- Inifile Reuse

The Ansible Collection `/playbooks/vars` directory includes sample variable files for:
- `sap_swpm` 'Default mode' to generate inifile.params of...
- SAP BW/4HANA OneHost
- SAP S/4HANA Distributed - ASCS, DBCI, ERS, PAS
- SAP S/4HANA OneHost
- SAP S/4HANA System Copy OneHost
- SAP Solution Manager (ABAP)
- SAP Solution Manager (JAVA)
- SAP Web Dispatcher
- SAP System Rename
- `sap_swpm` 'Default Templates mode' to generate inifile.params of...
- SAP S/4HANA OneHost
- SAP S/4HANA System Copy OneHost
- SAP System Rename
- `sap_swpm` 'Advanced mode' to generate inifile.params of...
- SAP S/4HANA OneHost
- `sap_swpm` 'Advanced Templates mode' to generate inifile.params of...
- SAP BW/4HANA OneHost
- SAP S/4HANA Distributed - ASCS, DBCI, ERS, PAS
- SAP S/4HANA OneHost
- SAP S/4HANA System Copy OneHost
- SAP Solution Manager (ABAP)
- SAP Solution Manager (JAVA)
- SAP Web Dispatcher
- SAP System Rename
- `sap_swpm` 'Inifile Reuse mode' inifile.params file for...
- SAP S/4HANA OneHost

NOTE: these are only sample files, they are meant to be edited by the user before execution and do not cover all scenarios possible (the Ansible Role can execute ant SAP SWPM installation)
### Migrating playbooks from previous versions of sap_swpm
The following role parameter is no longer used because there are no role `modes` any more:
#### sap_swpm_ansible_role_mode

The following two role parameters have been renamed, without automatic conversion between old and new name:

#### sap_swpm_inifile_list -> sap_swpm_inifile_sections_list
Previous name: sap_swpm_inifile_list
New name: sap_swpm_inifile_sections_list
Reason: This variable contains sections of the sapinst input file, `inifile.params`.
The new variable name is reflecting this purpose.

#### sap_swpm_inifile_custom_values_dictionary -> sap_swpm_inifile_parameters_dict
Previous name: sap_swpm_inifile_custom_values_dictionary
marcelmamula marked this conversation as resolved.
Show resolved Hide resolved
New name: sap_swpm_inifile_parameters_dict
Reason: This variable contains parameter names and values of the sapinst input file, `inifile.params`.
The new variable name is reflecting this purpose.

#### Migration from the `*_templates` modes of the previous version of sap_swpm
The role `sap_swpm` does no longer use the dictionary `sap_swpm_templates_install_dictionary`.
This dictionary was used in the previous role modes `default_templates` and `advanced_templates.
marcelmamula marked this conversation as resolved.
Show resolved Hide resolved

Because of this, required low level members of `sap_swpm_templates_install_dictionary` have to be redefined to top level variables.
Creating top level variables from low level members of a dict can be done:

- in a separate task using ansible.builtin.set_fact before calling sap_swpm, or

- in the task calling sap_swpm with a vars: section of the task calling sap_swpm.

Be aware of the following limitation: You cannot define a variable in the same task in which you use this variable to access a member
of another variable. Any variable which is used to access low level dict members has to be defined before, in a separate task.

Example:
For defining `sap_swpm_product_catalog_id` from a low level member of `sap_swpm_templates_install_dictionary`, use the following code:

```
# Step 1: Define level 2 dict member for accessing level 3 dict member in the following task
- name: Define variable sap_swpm_templates_product_input
ansible.builtin.set_fact:
sap_swpm_templates_product_input: "{{ sap_swpm_templates_product_input_prefix }}_nwas_ascs_ha"

# Step 2: Define top level variable from level 3 dict member
- name: Define variables sap_swpm_product_catalog_id and sap_swpm_inifile_sections_list
ansible.builtin.set_fact:
sap_swpm_product_catalog_id: "{{ sap_swpm_templates_install_dictionary[sap_swpm_templates_product_input]['sap_swpm_product_catalog_id'] }}"
sap_swpm_inifile_sections_list: "{{ sap_swpm_templates_install_dictionary[sap_swpm_templates_product_input][sap_swpm_inifile_sections_list] }}"
sap_swpm_inifile_parameters_dict: "{{ sap_swpm_templates_install_dictionary[sap_swpm_templates_product_input]['sap_swpm_inifile_parameters_dict'] }}"

```

## Execution

Expand All @@ -133,7 +141,7 @@ Sample Ansible Playbook Execution
- hosts: all
become: true
roles:
- { role: sap_swpm }
- sap_swpm
```

## Execution Flow
Expand All @@ -153,75 +161,52 @@ Sample Ansible Playbook Execution

- Get all .SAR filenames from `sap_swpm_software_path`

- Update `/etc/hosts` (optional - yes by default)
- Update `/etc/hosts` (optional - `false` by default)

- Apply firewall rules for SAP HANA (optional - no by default)
- Apply firewall rules for SAP HANA (optional - `false` by default)

- Process SAP SWPM `inifile.params` based on inputs
- At this stage, the role is searching for a sapinst inifile on the managed node, or it will create one:

### SAP SWPM
- If a file `inifile.params` is located on the managed node in the directory specified in `sap_swpm_inifile_directory`,
the role will not create a new one but rather download this file to the control node.

- Execute SWPM
- If such a file does *not* exist, the role will create an SAP SWPM `inifile.params` file by one of the following methods:

### Post-Install
Method 1: Predefined sections of the file inifile_params.j2 will be used to create the file `inifile.params`.
The variable `sap_swpm_inifile_sections_list` contains a list of sections which will part of the file `inifile.params`.
All other sections will be ignored. The inifile parameters themselves will be set according to other role parameters.
Example: The inifile parameter `archives.downloadBasket` will be set to the content of the role parameter
`sap_swpm_software_path`.

- Set expiry of Unix created users to 'never'
Method 2: The file `inifile.params` will be configured from the content of the dictionary `sap_swpm_inifile_parameters_dict`.
This dictionary is defined like in the following example:

- Apply firewall rules for SAP NW (optional - no by default)
```
sap_swpm_inifile_parameters_dict:
archives.downloadBasket: /software/download_basket
NW_getFQDN.FQDN: poc.cloud
```

It is also possible to use method 1 for creating the inifile and then replace or set additional variables using method 2:
Just define both of the related parameters, `sap_swpm_inifile_sections_list` and `sap_swpm_inifile_parameters_dict`.

## Execution Modes
- The file `inifile.params` is then transferred to a temporary directory on the managed node, to be used by the sapinst process.

Every SAP Software installation via SAP Software Provisioning Manager (SWPM) is possible, there are different Ansible Role execution modes available:
### SAP SWPM

- Default (`sap_swpm_templates_product_input: default`), run software install tasks using easy Ansible Variable to generate SWPM Unattended installations
- Default Templates (`sap_swpm_templates_product_input: default_templates`), optional use of templating definitions for repeated installations
- Advanced (`sap_swpm_templates_product_input: advanced`), run software install tasks with Ansible Variables one-to-one matched to SWPM Unattended Inifile parameters to generate bespoke SWPM Unattended installations
- Advanced Templates (`sap_swpm_templates_product_input: advanced_templates`), optional use of templating definitions for repeated installations
- Inifile Reuse (`sap_swpm_templates_product_input: inifile_reuse`), run previously-defined installations with an existing SWPM Unattended inifile.params
- Execute SWPM. This and the remaining steps can be skipped by setting the default of the parameter `sap_swpm_run_sapinst` to `false`.

### Default Templates mode variables
### Post-Install

Example using all inifile list parameters with the Default Templates mode to install SAP ECC EhP8 on IBM Db2:
- Set expiry of Unix created users to 'never'

```
sap_swpm_ansible_role_mode: default_templates
sap_swpm_templates_product_input: default_templates

sap_swpm_templates_install_dictionary:

template_name_ecc_ehp8_ibmdb2:

sap_swpm_product_catalog_id: NW_ABAP_OneHost:BS2016.ERP608.DB6.PD
sap_swpm_inifile_dictionary:
sap_swpm_sid:
...
sap_swpm_inifile_list:
- swpm_installation_media
- swpm_installation_media_swpm1
- swpm_installation_media_swpm1_exportfiles
- swpm_installation_media_swpm1_ibmdb2
- sum_config
- credentials
- credentials_anydb_ibmdb2
- db_config_anydb_all
- db_config_anydb_ibmdb2
- db_connection_nw_anydb_ibmdb2
- nw_config_anydb
- nw_config_other
- nw_config_central_services_abap
# - nw_config_central_services_java
- nw_config_primary_application_server_instance
- nw_config_ports
- nw_config_host_agent
# - nw_config_post_abap_reports
- sap_os_linux_user
```
- Apply firewall rules for SAP NW (optional - false by default)

## Tags

With the following tags, the role can be called to perform certain activities only:
- tag `sap_swpm_generate_inifile`: Only create the sapinst inifile. This can be useful for checking if the inifile is created as desired.
- tag `sap_swpm_generate_inifile`: Only create the sapinst inifile, without running most of the preinstall steps.
This can be useful for checking if the inifile is created as desired.
- tag `sap_swpm_sapinst_commandline`: Only show the sapinst command line.
- tag `sap_swpm_pre_install`: Perform all preinstallation steps, then exit.
- tag `sap_swpm_setup_firewall`: Only perform the firewall preinstallation settings (but only if variable `sap_swpm_setup_firewall` is set to `true`).
Expand Down
22 changes: 13 additions & 9 deletions roles/sap_swpm/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
# SWPM Ansible Role variables
########################################

sap_swpm_ansible_role_mode: "default"
# We do not use role modes any more:
# sap_swpm_ansible_role_mode: "default"
# default
# default_templates
# advanced
Expand Down Expand Up @@ -45,30 +46,29 @@ sap_swpm_files_non_sapcar_group: root

########################################
# SWPM Ansible Role variables
# for Inifile Reuse, Advanced, and Defaults/Advanced Templates Mode
# for creating the sapinst inifile
########################################

# Have the role run the sapinst command with an existing inifile or after creating the inifile:
sap_swpm_run_sapinst: true

# Inifile Reuse Mode
sap_swpm_inifile_reuse_source:
sap_swpm_inifile_reuse_destination:

# Advanced Mode
#sap_swpm_inifile_custom_values_dictionary:
#sap_swpm_inifile_parameters_dict:
# archives.downloadBasket: /software/download_basket
# NW_getFQDN.FQDN: poc.cloud
## add.additional.parameters: ''

# Default/Advanced Templates Mode
#sap_swpm_templates_product_input: ""


########################################
# SWPM Ansible Role variables
# for Default Mode
# - List of inifile parameters to generate
########################################

sap_swpm_inifile_list:
sap_swpm_inifile_sections_list:
- swpm_installation_media
- swpm_installation_media_swpm2_hana
# - swpm_installation_media_swpm1
Expand Down Expand Up @@ -156,7 +156,7 @@ sap_swpm_software_extract_directory: # e.g. /software/sap_swpm_extracted
sap_swpm_software_use_media: 'false'

# Main path that this role will look for .SAR files
sap_swpm_software_path:
#sap_swpm_software_path: /software/sapfiles
## This directory path should include these files:
## - igs*sar
## - igshelper*sar
Expand All @@ -165,6 +165,10 @@ sap_swpm_software_path:
## - IMDB_CLIENT*SAR
## - SAPHOSTAGENT*SAR

# Directory in which a sapinst inifile which is to be used by the role can be stored:
sap_swpm_inifile_directory: '/software/sap_swpm/inifiles'
#sap_swpm_local_inifile_directory: '/tmp/inifiles'

# SWPM1 - paths that this role will look for CD Media software
sap_swpm_cd_export_pt1_path:
sap_swpm_cd_export_pt2_path:
Expand Down
2 changes: 2 additions & 0 deletions roles/sap_swpm/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@

- name: SAP SWPM - run swpm
ansible.builtin.import_tasks: swpm.yml
when: sap_swpm_run_sapinst
tags:
- sap_swpm_install

- name: SAP SWPM - run postinstall task
ansible.builtin.import_tasks: post_install.yml
when: sap_swpm_run_sapinst
Loading
Loading