Skip to content

Commit

Permalink
feat: hana and netweaver preconfigure for Suse
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelmamula committed Jan 17, 2025
1 parent 4425cd1 commit 85de6d2
Show file tree
Hide file tree
Showing 60 changed files with 1,640 additions and 786 deletions.
2 changes: 1 addition & 1 deletion roles/sap_general_preconfigure/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ The IPV4 address to be used for updating or checking `/etc/hosts` entries.<br>
### sap_general_preconfigure_db_group_name
- _Type:_ `str`

Use this variable to specify the name of the RHEL group which is used for the database processes.<br>
(RedHat specific) Use this variable to specify the name of the RHEL group which is used for the database processes.<br>
If defined, it will be used to configure process limits as per step<br>
Configuring Process Resource Limits<br>

Expand Down
4 changes: 2 additions & 2 deletions roles/sap_general_preconfigure/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ sap_general_preconfigure_envgroups: "{{ __sap_general_preconfigure_envgroups }}"
# Example: See README.md

sap_general_preconfigure_packages: "{{ __sap_general_preconfigure_packages }}"
# The list of packages to install.
# 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.

sap_general_preconfigure_min_package_check: true
Expand Down Expand Up @@ -164,7 +164,7 @@ sap_general_preconfigure_domain: "{{ sap_domain | d(ansible_domain) }}"
# The DNS domain name to be used for updating or checking `/etc/hosts` entries.

# sap_general_preconfigure_db_group_name: (not defined by default)
# Use this variable to specify the name of the RHEL group which is used for the database processes.
# (RedHat specific) Use this variable to specify the name of the RHEL group which is used for the database processes.
# If defined, it will be used to configure process limits as per step
# Configuring Process Resource Limits
# Example: See README.md
Expand Down
23 changes: 17 additions & 6 deletions roles/sap_general_preconfigure/handlers/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
- sap_general_preconfigure_run_grub2_mkconfig | d(true)

- name: "Run grub-mkconfig (BIOS mode)"
ansible.builtin.command: grub2-mkconfig -o /boot/grub2/grub.cfg
ansible.builtin.command:
cmd: grub2-mkconfig -o /boot/grub2/grub.cfg
register: __sap_general_preconfigure_register_grub2_mkconfig_bios_mode
changed_when: true
listen: __sap_general_preconfigure_regenerate_grub2_conf_handler
Expand Down Expand Up @@ -52,7 +53,8 @@
- ansible_distribution == 'SLES' or ansible_distribution == 'SLES_SAP'

- name: "Run grub-mkconfig (UEFI mode)"
ansible.builtin.command: "grub2-mkconfig -o {{ __sap_general_preconfigure_uefi_boot_dir }}"
ansible.builtin.command:
cmd: "grub2-mkconfig -o {{ __sap_general_preconfigure_uefi_boot_dir }}"
register: __sap_general_preconfigure_register_grub2_mkconfig_uefi_mode
changed_when: true
listen: __sap_general_preconfigure_regenerate_grub2_conf_handler
Expand Down Expand Up @@ -85,8 +87,8 @@
- name: Wait for Zypper lock to be released
ansible.builtin.command:
cmd: zypper info zypper
retries: 60
timeout: 5
retries: 20
timeout: 30
listen: __sap_general_preconfigure_reboot_handler
when:
- ansible_os_family == 'Suse'
Expand All @@ -110,16 +112,25 @@
- not sap_general_preconfigure_fail_if_reboot_required | d(true)
- not sap_general_preconfigure_reboot_ok | d(false)

- name: Unmask packagekit.service
ansible.builtin.systemd_service:
name: packagekit.service
masked: false
listen: __sap_general_preconfigure_packagekit_handler


# Reasons for noqa:
# - command-instead-of-module: We want to avoid non-ansible.builtin modules where possible
# - no-changed-when: Remounting does not do any harm and does not affect idempotency.
- name: Remount /dev/shm # noqa command-instead-of-module no-changed-when
ansible.builtin.command: mount -o remount /dev/shm
ansible.builtin.command:
cmd: mount -o remount /dev/shm
listen: __sap_general_preconfigure_mount_tmpfs_handler
tags: molecule-idempotence-notest

- name: Check if /dev/shm is available
ansible.builtin.command: df -h /dev/shm
ansible.builtin.command:
cmd: df -h /dev/shm
register: __sap_general_preconfigure_command_df_shm_result
changed_when: false
listen: __sap_general_preconfigure_mount_tmpfs_handler
Expand Down
15 changes: 15 additions & 0 deletions roles/sap_general_preconfigure/tasks/SLES/assert-installation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
cmd: "rpm -q --whatprovides {{ item }}"
register: __sap_general_preconfigure_register_whatprovides
changed_when: false
ignore_errors: true
loop: "{{ sap_general_preconfigure_packages }}"


Expand Down Expand Up @@ -41,6 +42,8 @@
- name: Get info about possible package updates # noqa command-instead-of-module
ansible.builtin.command:
cmd: zypper -q patch-check
timeout: 120
retries: 5
register: __sap_general_preconfigure_register_zypper_check_update_assert
changed_when: false
ignore_errors: true # true, because unpatched system is always error.
Expand Down Expand Up @@ -76,3 +79,15 @@
fail_msg: "FAIL: System needs to be restarted!"
success_msg: "PASS: System needs no restart."
ignore_errors: "{{ sap_general_preconfigure_assert_ignore_errors | d(false) }}"


- name: Assert saptune is at requested version
ansible.builtin.assert:
that: ansible_facts.packages['saptune'][0]['version'] == sap_general_preconfigure_saptune_version
fail_msg: "FAIL: saptune version installed is {{ ansible_facts.packages['saptune'][0]['version']
}} but the version {{ sap_general_preconfigure_saptune_version }} was expected"
success_msg: "PASS: the installed version of saptune meets the expected version: {{ sap_general_preconfigure_saptune_version }}"
when:
- __sap_general_preconfigure_use_saptune
- sap_general_preconfigure_saptune_version is defined
- sap_general_preconfigure_saptune_version | length > 0
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@


- name: Trigger grub update if necessary # noqa no-changed-when
ansible.builtin.command: /bin/true
ansible.builtin.command:
cmd: /bin/true
notify: __sap_general_preconfigure_regenerate_grub2_conf_handler
when:
- (__sap_general_preconfigure_grub_update.results | selectattr('changed', 'equalto', true) | list | length > 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,17 @@
when: __sap_general_preconfigure_use_saptune | d(true)
block:
- name: Ensure latest saptune is installed
community.general.zypper:
type: package
ansible.builtin.package:
name: saptune
state: present
when:
- sap_general_preconfigure_saptune_version is undefined
or sap_general_preconfigure_saptune_version | length == 0

- name: Ensure specific saptune version is installed
community.general.zypper:
type: package
ansible.builtin.package:
name: "saptune={{ sap_general_preconfigure_saptune_version }}"
state: present
force: true
when:
- sap_general_preconfigure_saptune_version is defined
- sap_general_preconfigure_saptune_version | length > 0
Expand All @@ -44,8 +41,6 @@
when: not __sap_general_preconfigure_use_saptune | d(true)
block:
- name: Ensure sapconf is installed
community.general.zypper:
type: package
ansible.builtin.package:
name: "sapconf"
state: present
force: true
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
when: "'sapconf' in ansible_facts.packages"

- name: Make sure that sapconf and tuned are stopped and disabled
ansible.builtin.command: "saptune service takeover"
ansible.builtin.command:
cmd: "saptune service takeover"
register: __sap_general_preconfigure_register_saptune_takeover
changed_when: __sap_general_preconfigure_register_saptune_takeover.rc == 0

Expand Down Expand Up @@ -54,14 +55,15 @@
changed_when: false


- name: Enable saptune solution
- name: Check active 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
ansible.builtin.command: saptune solution enabled
ansible.builtin.command:
cmd: saptune solution enabled
register: __sap_general_preconfigure_register_saptune_status
changed_when: false

Expand Down
49 changes: 40 additions & 9 deletions roles/sap_general_preconfigure/tasks/SLES/installation.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,34 @@
# SPDX-License-Identifier: Apache-2.0
---

# Both sap_general_preconfigure_packages and __sap_general_preconfigure_min_pkgs are installed at same time.
- name: Gather service facts
ansible.builtin.service_facts:

# Service packagekit is part of PackageKit-backend-zypp (SLE-Module-Desktop-Applications)
# This service creates zypper locks and causes package install failures.
# Service cannot be disabled and we have to mask its execution.
- name: Mask packagekit.service when present
ansible.builtin.systemd_service:
name: packagekit.service
masked: true
when: "'packagekit.service' in ansible_facts.services"
notify: __sap_general_preconfigure_packagekit_handler


- name: Wait for stop of packagekit.service
ansible.builtin.shell: |
set -o pipefail && bash -c '
while (ps aux | grep "[z]ypper" | grep -v grep) || (ps aux | grep "/usr/lib/packagekitd" | grep -v grep) ||
([ -f /var/run/zypp.pid ] && [ -s /var/run/zypp.pid ]); do
sleep 10;
done'
register: __packagekit_service_check
changed_when: false
until: __packagekit_service_check.rc == 0
retries: 60
when: "'packagekit.service' in ansible_facts.services"


- name: Ensure that the required packages are installed
ansible.builtin.package:
state: present
Expand All @@ -10,8 +37,7 @@


- name: Install minimum packages if required
community.general.zypper:
type: package
ansible.builtin.package:
name: '{{ line_item[0] }}>={{ line_item[1] }}'
state: present
loop: "{{ __sap_general_preconfigure_min_pkgs }}"
Expand All @@ -22,16 +48,16 @@
- __sap_general_preconfigure_min_pkgs | d([])


# Reason for noqa: Both yum and dnf support "state: latest"
# Reason for noqa: Zypper supports "state: latest"
- name: Ensure that the system is updated to the latest patchlevel # noqa package-latest
ansible.builtin.package:
state: latest
name: "*"
register: __sap_general_preconfigure_register_update_latest
when: sap_general_preconfigure_update | bool


# Sapconf is present on: SLES 15
# Saptune is present on: SLES_SAP 15, SLES_SAP 16
# 1275776 - Linux: Preparing SLES for SAP environments
- name: Install saptune if available
ansible.builtin.include_tasks:
file: generic/saptune_install.yml
Expand All @@ -43,7 +69,8 @@

# Reason for noqa: The command to be executed might contain pipes
- name: Determine if the system needs to be restarted # noqa command-instead-of-shell
ansible.builtin.shell: "zypper ps"
ansible.builtin.shell:
cmd: "zypper ps"
register: __sap_general_preconfigure_register_needs_restarting
ignore_errors: true
changed_when: false
Expand All @@ -62,17 +89,21 @@
- name: For needs-restarting - Set the flag that reboot is needed to apply changes
ansible.builtin.set_fact:
sap_general_preconfigure_fact_reboot_required: true
when: __sap_general_preconfigure_register_needs_restarting is failed
when:
- __sap_general_preconfigure_register_needs_restarting is failed
or __sap_general_preconfigure_register_update_latest.changed

- name: For needs-restarting - Display the content of sap_general_preconfigure_fact_reboot_required
ansible.builtin.debug:
var: sap_general_preconfigure_fact_reboot_required


- name: Call Reboot handler if necessary
ansible.builtin.command: /bin/true
ansible.builtin.command:
cmd: /bin/true
notify: __sap_general_preconfigure_reboot_handler
changed_when: true
when:
- __sap_general_preconfigure_register_needs_restarting is failed
or __sap_general_preconfigure_register_needs_restarting.rc == 102
or __sap_general_preconfigure_register_update_latest.changed
5 changes: 1 addition & 4 deletions roles/sap_general_preconfigure/tasks/sapnote/2578899.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,11 @@

- name: Set fact for SAP note number 2578899
ansible.builtin.set_fact:
__sap_general_preconfigure_packages_2578899:
- uuidd
- sysstat
- sysctl-logger
__sap_general_preconfigure_services_2578899:
- uuidd.socket
- sysstat
- sysctl-logger.service

__sap_general_preconfigure_grub_cmdline_2578899: []
# I/O Scheduler parameter is already part of default saptune and sapconf configuration.
# - "elevator=noop"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# SPDX-License-Identifier: Apache-2.0
---

- name: Ensure that the required packages are installed - 2578899
- name: Ensure that the required packages are installed
ansible.builtin.package:
name: "{{ __sap_general_preconfigure_packages_2578899 }}"
state: present
name: "{{ item }}"
loop: "{{ __sap_general_preconfigure_packages_2578899 }}"
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,11 @@

- name: Set fact for SAP note number 2578899
ansible.builtin.set_fact:
__sap_general_preconfigure_packages_2578899:
- uuidd
- sysstat
- sysctl-logger
__sap_general_preconfigure_services_2578899:
- uuidd.socket
- sysstat
- sysctl-logger.service

__sap_general_preconfigure_grub_cmdline_2578899: []
# I/O Scheduler parameter is already part of default saptune and sapconf configuration.
# - "elevator=noop"
Expand Down
9 changes: 8 additions & 1 deletion roles/sap_general_preconfigure/vars/SLES_15.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,17 @@ __sap_general_preconfigure_packages:
- bind-utils
- hostname

# Packages specific for SAP Note 2578899
# Their services are enabled using __sap_general_preconfigure_services_2578899
__sap_general_preconfigure_packages_2578899:
- uuidd
- sysstat
- sysctl-logger

__sap_general_preconfigure_min_pkgs: []
__sap_general_preconfigure_packagegroups:
__sap_general_preconfigure_envgroups:
__sap_general_preconfigure_kernel_parameters_default: []

# SLES is using sapconf
# SLES_SAP is using saptune, but SLES is using sapconf.
__sap_general_preconfigure_use_saptune: false
8 changes: 7 additions & 1 deletion roles/sap_general_preconfigure/vars/SLES_SAP_15.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,17 @@ __sap_general_preconfigure_packages:
- nfs-utils
- bind-utils

# Packages specific for SAP Note 2578899
# Their services are enabled using __sap_general_preconfigure_services_2578899
__sap_general_preconfigure_packages_2578899:
- uuidd
- sysstat
- sysctl-logger

__sap_general_preconfigure_min_pkgs: []
__sap_general_preconfigure_packagegroups:
__sap_general_preconfigure_envgroups:
__sap_general_preconfigure_kernel_parameters_default: []

# SLES_SAP is using saptune
# SLES_SAP is using saptune, but SLES is using sapconf.
__sap_general_preconfigure_use_saptune: true
5 changes: 2 additions & 3 deletions roles/sap_general_preconfigure/vars/SLES_SAP_16.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
# Variables specific to following versions:
# - SUSE Linux Enterprise Server for SAP Applications 16

__sap_general_preconfigure_sapnotes_versions:
# TODO: Update when SLES 16 version of 2578899 is available.
__sap_general_preconfigure_sapnotes_versions: []

__sap_general_preconfigure_packages:
# Mandatory patterns
Expand All @@ -29,5 +28,5 @@ __sap_general_preconfigure_packagegroups:
__sap_general_preconfigure_envgroups:
__sap_general_preconfigure_kernel_parameters_default: []

# SLES_SAP is using saptune
# SLES_SAP is using saptune, but SLES is using sapconf.
__sap_hana_preconfigure_use_saptune: true
Loading

0 comments on commit 85de6d2

Please sign in to comment.