Skip to content

sap_*_preconfigure/SLES: Enhance saptune handling and detection #994

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

Merged
merged 3 commits into from
Mar 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
11 changes: 9 additions & 2 deletions roles/sap_general_preconfigure/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ If you set the RHEL minor release, then you must also use the `eus` or `e4s` rep
- _Type:_ `str`
- _Default:_ (set by platform/environment specific variables)

The name of the software package group to install.<br>
(RedHat specific) The name of the software package group to install.<br>
The default for this parameter is set in the vars file which corresponds to the detected OS version.<br>

Example:
Expand All @@ -271,7 +271,7 @@ Example:
- _Type:_ `str`
- _Default:_ (set by platform/environment specific variables)

The name of the software environment group to check.<br>
(RedHat specific) The name of the software environment group to check.<br>
The default for this parameter is set in the vars file which corresponds to the detected OS version.<br>

Example:
Expand All @@ -280,6 +280,13 @@ Example:
'@minimal-environment'
```

### sap_general_preconfigure_patterns
- _Type:_ `list` with elements of type `str`
- _Default:_ (set by platform/environment specific variables)

(SUSE specific) The list of the zypper patterns to install.<br>
The default for this parameter is set in the vars file which corresponds to the detected OS version.<br>

### sap_general_preconfigure_packages
- _Type:_ `list` with elements of type `str`
- _Default:_ (set by platform/environment specific variables)
Expand Down
8 changes: 6 additions & 2 deletions roles/sap_general_preconfigure/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,19 @@ sap_general_preconfigure_set_minor_release: false
# If you set the RHEL minor release, then you must also use the `eus` or `e4s` repos.

sap_general_preconfigure_packagegroups: "{{ __sap_general_preconfigure_packagegroups }}"
# The name of the software package group to install.
# (RedHat specific) The name of the software package group to install.
# The default for this parameter is set in the vars file which corresponds to the detected OS version.
# Example: See README.md

sap_general_preconfigure_envgroups: "{{ __sap_general_preconfigure_envgroups }}"
# The name of the software environment group to check.
# (RedHat specific) The name of the software environment group to check.
# The default for this parameter is set in the vars file which corresponds to the detected OS version.
# Example: See README.md

sap_general_preconfigure_patterns: "{{ __sap_general_preconfigure_patterns }}"
# (SUSE specific) The list of the zypper patterns to install.
# The default for this parameter is set in the vars file which corresponds to the detected OS version.

sap_general_preconfigure_packages: "{{ __sap_general_preconfigure_packages }}"
# The list of packages to be installed.
# The default for this variable is set in the vars file which corresponds to the detected OS version.
Expand Down
13 changes: 11 additions & 2 deletions roles/sap_general_preconfigure/meta/argument_specs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ argument_specs:
sap_general_preconfigure_packagegroups:
default: "{{ __sap_general_preconfigure_packagegroups }}"
description:
- The name of the software package group to install.
- (RedHat specific) The name of the software package group to install.
- The default for this parameter is set in the vars file which corresponds to the detected OS version.
example:
'@minimal-environment'
Expand All @@ -162,13 +162,22 @@ argument_specs:
sap_general_preconfigure_envgroups:
default: "{{ __sap_general_preconfigure_envgroups }}"
description:
- The name of the software environment group to check.
- (RedHat specific) The name of the software environment group to check.
- The default for this parameter is set in the vars file which corresponds to the detected OS version.
example:
'@minimal-environment'
required: false
type: str

sap_general_preconfigure_patterns:
default: "{{ __sap_general_preconfigure_patterns }}"
description:
- (SUSE specific) The list of the zypper patterns to install.
- The default for this parameter is set in the vars file which corresponds to the detected OS version.
required: false
type: list
elements: str

sap_general_preconfigure_packages:
default: "{{ __sap_general_preconfigure_packages }}"
description:
Expand Down
16 changes: 16 additions & 0 deletions roles/sap_general_preconfigure/tasks/SLES/assert-installation.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
# SPDX-License-Identifier: Apache-2.0
---

- name: Query installed zypper patterns
ansible.builtin.command:
cmd: zypper patterns --installed-only
register: __sap_general_preconfigure_register_patterns
changed_when: false
ignore_errors: true

- name: Assert that all required zypper patterns are installed
ansible.builtin.assert:
that: "'{{ item }}' in __sap_general_preconfigure_register_patterns.stdout"
fail_msg: "FAIL: Pattern '{{ item }}' is not installed!"
success_msg: "PASS: Pattern '{{ item }}' is installed."
loop: "{{ sap_general_preconfigure_patterns }}"
ignore_errors: "{{ sap_general_preconfigure_assert_ignore_errors | d(false) }}"


# Both sap_general_preconfigure_packages and __sap_general_preconfigure_min_pkgs are checked at same time.
# Check rpm --whatprovides only if package cannot be found directly.
- name: Query RPM packages
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,27 +62,29 @@
changed_when: false


- name: Check active saptune solution
- name: Block to show current enabled saptune solution
when:
- __sap_general_preconfigure_use_saptune
- __sap_general_preconfigure_register_saptune_check_before.rc == 0
or (__sap_general_preconfigure_register_saptune_check_after.rc == 0)
block:
- name: Discover active solution
- name: Get current enabled saptune solution
ansible.builtin.command:
cmd: saptune solution enabled
register: __sap_general_preconfigure_register_saptune_status
register: __sap_general_preconfigure_register_saptune_enabled
changed_when: false
failed_when: false

- name: Set fact for active solution
# Enabled solution contains newline, which has to be removed
- name: Cleanup saptune solution enabled output
ansible.builtin.set_fact:
# Capture the first block on none whitespace
__sap_general_preconfigure_register_solution_configured:
"{{ (__sap_general_preconfigure_register_saptune_status.stdout | regex_search('(\\S+)', '\\1'))[0] | default('NONE') }}"
__sap_general_preconfigure_register_saptune_enabled_trim:
"{{ __sap_general_preconfigure_register_saptune_enabled.stdout | trim | replace('\n', '') }}"

- name: Show configured solution
- name: Show current enabled saptune solution
ansible.builtin.debug:
var: __sap_general_preconfigure_register_solution_configured
msg: "{{ __sap_general_preconfigure_register_saptune_enabled_trim }}"
when: __sap_general_preconfigure_register_saptune_enabled_trim != ''


- name: Enable sapconf
Expand Down
16 changes: 16 additions & 0 deletions roles/sap_general_preconfigure/tasks/SLES/installation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,22 @@
when: "'packagekit.service' in ansible_facts.services"


# Pattern installation will run only if pattern is not installed
# This ensures that command module shows correct changed status
- name: Query installed zypper patterns
ansible.builtin.command:
cmd: zypper patterns --installed-only
register: __sap_general_preconfigure_register_patterns
changed_when: false
ignore_errors: true

- name: Ensure that the required zypper patterns are installed
ansible.builtin.command:
cmd: zypper install -y -t pattern {{ item }}
loop: "{{ sap_general_preconfigure_patterns }}"
when: item not in __sap_general_preconfigure_register_patterns.stdout
changed_when: item not in __sap_general_preconfigure_register_patterns.stdout

- name: Ensure that the required packages are installed
ansible.builtin.package:
state: present
Expand Down
6 changes: 6 additions & 0 deletions roles/sap_general_preconfigure/vars/SLES_15.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,13 @@ __sap_general_preconfigure_sapnotes_versions:
# 2369910 - SAP Software on Linux: General information
- { number: '2369910', version: '18' }

__sap_general_preconfigure_patterns:
- sap_server

__sap_general_preconfigure_packages:
# Patterns are not included in package list
# Ansible package module skips recommended packages resulting in discrepancies.

- uuidd
- tcsh
- psmisc
Expand Down
7 changes: 5 additions & 2 deletions roles/sap_general_preconfigure/vars/SLES_SAP_15.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@ __sap_general_preconfigure_sapnotes_versions:
# 2369910 - SAP Software on Linux: General information
- { number: '2369910', version: '18' }

__sap_general_preconfigure_patterns:
- sap_server

__sap_general_preconfigure_packages:
# Mandatory patterns
- patterns-server-enterprise-sap_server
# Patterns are not included in package list
# Ansible package module skips recommended packages resulting in discrepancies.

# Recommended packages
- tcsh
Expand Down
7 changes: 5 additions & 2 deletions roles/sap_general_preconfigure/vars/SLES_SAP_16.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@

__sap_general_preconfigure_sapnotes_versions: []

__sap_general_preconfigure_patterns:
- sles_minimal_sap

__sap_general_preconfigure_packages:
# Mandatory patterns
- patterns-sap-base_sap_server
# Patterns are not included in package list
# Ansible package module skips recommended packages resulting in discrepancies.

# Recommended packages
- tcsh
Expand Down
1 change: 1 addition & 0 deletions roles/sap_general_preconfigure/vars/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# dummy entries for passing the arg spec validation:
__sap_general_preconfigure_packagegroups: ''
__sap_general_preconfigure_envgroups: ''
__sap_general_preconfigure_patterns: []
__sap_general_preconfigure_packages: []
__sap_general_preconfigure_size_of_tmpfs_gb: ''
__sap_general_preconfigure_kernel_parameters_default: []
13 changes: 13 additions & 0 deletions roles/sap_hana_preconfigure/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,13 @@ or a list of the minimum required packages for SAP HANA server (parameter `__sap
SAP HANA requires certain minimum package versions to be supported. These minimum levels are listed in SAP Note 2235581.<br>
Set this parameter to `false` if you want to ignore these requirements.<br>

### sap_hana_preconfigure_patterns
- _Type:_ `list` with elements of type `str`
- _Default:_ (set by platform/environment specific variables)

(SUSE specific) The list of the zypper patterns to install.<br>
The default for this parameter is set in the vars file which corresponds to the detected OS version.<br>

### sap_hana_preconfigure_update
- _Type:_ `bool`
- _Default:_ `false`
Expand Down Expand Up @@ -449,6 +456,12 @@ This will replace the current installed version if present, even downgrade if ne
(SUSE specific) Specifies the saptune solution to apply.<br>
Available values: `HANA`, `NETWEAVER+HANA`, `S4HANA-APP+DB`, `S4HANA-DBSERVER`

### sap_hana_preconfigure_saptune_solution_force
- _Type:_ `bool`
- _Default:_ `false`

(SUSE specific) Apply saptune solution regardless if it is already enabled and verified.<br>

### sap_hana_preconfigure_saptune_azure
- _Type:_ `bool`
- _Default:_ `false`
Expand Down
6 changes: 6 additions & 0 deletions roles/sap_hana_preconfigure/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ sap_hana_preconfigure_min_package_check: true
# SAP HANA requires certain minimum package versions to be supported. These minimum levels are listed in SAP Note 2235581.
# Set this parameter to `false` if you want to ignore these requirements.

sap_hana_preconfigure_patterns: "{{ __sap_hana_preconfigure_patterns }}"
# (SUSE specific) The list of the zypper patterns to install.
# The default for this parameter is set in the vars file which corresponds to the detected OS version.

sap_hana_preconfigure_update: false
# Set this parameter to `true` to update the system to the latest package levels.
# By setting the parameter `sap_general_preconfigure_set_minor_release` of the
Expand Down Expand Up @@ -181,6 +185,8 @@ sap_hana_preconfigure_saptune_version: ''
# Available options for HANA are: HANA, NETWEAVER+HANA, S4HANA-APP+DB, S4HANA-DBSERVER
sap_hana_preconfigure_saptune_solution: 'HANA'

# (SUSE specific) Apply saptune solution regardless if it is already enabled and verified.
sap_hana_preconfigure_saptune_solution_force: false

sap_hana_preconfigure_saptune_azure: false
# On Azure, TCP timestamps, reuse and recycle should be disabled (SLES for SAP Applications).
Expand Down
16 changes: 16 additions & 0 deletions roles/sap_hana_preconfigure/meta/argument_specs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,15 @@ argument_specs:
required: false
type: bool

sap_hana_preconfigure_patterns:
default: "{{ __sap_hana_preconfigure_patterns }}"
description:
- (SUSE specific) The list of the zypper patterns to install.
- The default for this parameter is set in the vars file which corresponds to the detected OS version.
required: false
type: list
elements: str

sap_hana_preconfigure_update:
default: 'false'
description:
Expand Down Expand Up @@ -383,6 +392,13 @@ argument_specs:
required: false
type: str

sap_hana_preconfigure_saptune_solution_force:
default: false
description:
- (SUSE specific) Apply saptune solution regardless if it is already enabled and verified.
required: false
type: bool

sap_hana_preconfigure_saptune_azure:
default: false
description:
Expand Down
16 changes: 16 additions & 0 deletions roles/sap_hana_preconfigure/tasks/SLES/assert-installation.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
# SPDX-License-Identifier: Apache-2.0
---

- name: Query installed zypper patterns
ansible.builtin.command:
cmd: zypper patterns --installed-only
register: __sap_hana_preconfigure_register_patterns
changed_when: false
ignore_errors: true

- name: Assert that all required zypper patterns are installed
ansible.builtin.assert:
that: "'{{ item }}' in __sap_hana_preconfigure_register_patterns.stdout"
fail_msg: "FAIL: Pattern '{{ item }}' is not installed!"
success_msg: "PASS: Pattern '{{ item }}' is installed."
loop: "{{ sap_hana_preconfigure_patterns }}"
ignore_errors: "{{ sap_hana_preconfigure_assert_ignore_errors | d(false) }}"


# Check rpm --whatprovides only if package cannot be found directly.
- name: Query RPM packages
ansible.builtin.shell:
Expand Down
32 changes: 30 additions & 2 deletions roles/sap_hana_preconfigure/tasks/SLES/configuration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,44 @@
- __sap_hana_preconfigure_use_saptune


- name: Get current enabled saptune solution
ansible.builtin.command:
cmd: "saptune solution enabled"
register: __sap_hana_preconfigure_register_solution_enabled
changed_when: false
failed_when: false
when: __sap_hana_preconfigure_use_saptune

# Enabled solution contains newline, which has to be removed
- name: Cleanup saptune solution enabled output
ansible.builtin.set_fact:
__sap_hana_preconfigure_register_solution_enabled_trim:
"{{ __sap_hana_preconfigure_register_solution_enabled.stdout | trim | replace('\n', '') }}"
when: __sap_hana_preconfigure_use_saptune

# Verify SAP Solution before block and revert if found invalid
- name: Verify saptune solution before changes
ansible.builtin.command:
cmd: "saptune solution verify {{ sap_hana_preconfigure_saptune_solution }}"
register: __sap_hana_preconfigure_register_solution_verify_before
changed_when: false
failed_when: false
when: __sap_hana_preconfigure_use_saptune
when:
- __sap_hana_preconfigure_use_saptune
- __sap_hana_preconfigure_register_solution_enabled_trim == sap_hana_preconfigure_saptune_solution

- name: Apply saptune solution
when:
- __sap_hana_preconfigure_use_saptune
- __sap_hana_preconfigure_register_solution_verify_before.rc != 0
- sap_hana_preconfigure_saptune_solution_force
or __sap_hana_preconfigure_register_solution_enabled_trim != sap_hana_preconfigure_saptune_solution
or __sap_hana_preconfigure_register_solution_verify_before.rc != 0
block:
- name: Show current enabled saptune solution
ansible.builtin.debug:
msg: "{{ __sap_hana_preconfigure_register_solution_enabled_trim }}"
when: __sap_hana_preconfigure_register_solution_enabled_trim != ''

- name: Revert saptune configuration
ansible.builtin.command:
cmd: "saptune revert all"
Expand All @@ -62,6 +86,10 @@
{{ __sap_hana_preconfigure_register_solution_verify_after.stderr_lines }}
when: __sap_hana_preconfigure_register_solution_verify_after.rc != 0

- name: Show applied saptune solution
ansible.builtin.debug:
msg: "{{ sap_hana_preconfigure_saptune_solution }}"


- name: Configure - Include configuration actions for required sapnotes
ansible.builtin.include_tasks: "sapnote/{{ sap_note_line_item.number }}.yml"
Expand Down
Loading