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_*_preconfigure/Suse: Rework of preconfigure roles for Suse, add missing notes. #930

Merged
merged 5 commits into from
Jan 23, 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
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
13 changes: 11 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,11 +164,20 @@ 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

sap_general_preconfigure_run_grub2_mkconfig: true
# By default, the role will run `grub2-mkconfig` to update the Grub configuration if necessary.
# Set this parameter to `false` if this is not desired.

# (SUSE specific) Version of saptune to install.
# It is recommended to install latest version by keeping this variable empty.
# This will replace the current installed version if present, even downgrade if necessary.
sap_general_preconfigure_saptune_version: ''

# in SAP Note 2369910 SAP requires English locale
# If you want to define the locale set this to e.g. en_US.UTF-8
sap_general_preconfigure_default_locale: ""
Expand Down
104 changes: 94 additions & 10 deletions roles/sap_general_preconfigure/handlers/main.yml
Original file line number Diff line number Diff line change
@@ -1,52 +1,136 @@
# SPDX-License-Identifier: Apache-2.0
---
# handlers file for sap_general_preconfigure

# BEGIN - GRUB section
- name: "Check if server is booted in BIOS or UEFI mode"
ansible.builtin.stat:
path: /sys/firmware/efi
get_checksum: false
register: __sap_general_preconfigure_register_stat_sys_firmware_efi
listen: __sap_general_preconfigure_regenerate_grub2_conf_handler
when:
- sap_general_preconfigure_run_grub2_mkconfig | d(true)

- name: Debug BIOS or UEFI
ansible.builtin.debug:
var: __sap_general_preconfigure_register_stat_sys_firmware_efi.stat.exists
listen: __sap_general_preconfigure_regenerate_grub2_conf_handler
when:
- sap_general_preconfigure_run_grub2_mkconfig | d(true)

- name: "Run grub-mkconfig (BIOS mode)"
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
notify: __sap_general_preconfigure_reboot_handler
when:
- not __sap_general_preconfigure_register_stat_sys_firmware_efi.stat.exists
- sap_general_preconfigure_run_grub2_mkconfig | d(true)

- name: "Debug grub-mkconfig BIOS mode"
ansible.builtin.debug:
var: __sap_general_preconfigure_register_grub2_mkconfig_bios_mode.stdout_lines,
__sap_general_preconfigure_register_grub2_mkconfig_bios_mode.stderr_lines
listen: __sap_general_preconfigure_regenerate_grub2_conf_handler
when:
- not __sap_general_preconfigure_register_stat_sys_firmware_efi.stat.exists
- sap_general_preconfigure_run_grub2_mkconfig | d(true)

- name: "Set the grub.cfg location RHEL"
ansible.builtin.set_fact:
__sap_general_preconfigure_uefi_boot_dir: /boot/efi/EFI/redhat/grub.cfg
listen: __sap_general_preconfigure_regenerate_grub2_conf_handler
when:
- ansible_distribution == 'RedHat'

- name: "Set the grub.cfg location SLES"
ansible.builtin.set_fact:
__sap_general_preconfigure_uefi_boot_dir: /boot/efi/EFI/BOOT/grub.cfg
listen: __sap_general_preconfigure_regenerate_grub2_conf_handler
when:
- ansible_distribution == 'SLES' or ansible_distribution == 'SLES_SAP'

- name: "Run grub-mkconfig (UEFI mode)"
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
notify: __sap_general_preconfigure_reboot_handler
when:
- __sap_general_preconfigure_register_stat_sys_firmware_efi.stat.exists
- sap_general_preconfigure_run_grub2_mkconfig | d(true)

- name: "Debug grub-mkconfig UEFI"
ansible.builtin.debug:
var: __sap_general_preconfigure_register_grub2_mkconfig_uefi_mode.stdout_lines,
__sap_general_preconfigure_register_grub2_mkconfig_uefi_mode.stderr_lines
listen: __sap_general_preconfigure_regenerate_grub2_conf_handler
when:
- __sap_general_preconfigure_register_stat_sys_firmware_efi.stat.exists
- sap_general_preconfigure_run_grub2_mkconfig | d(true)

# END - GRUB section


- name: Reboot the managed node
ansible.builtin.reboot:
test_command: /bin/true
listen: __sap_general_preconfigure_reboot_handler
when:
- sap_general_preconfigure_reboot_ok|d(false)
- sap_general_preconfigure_reboot_ok | d(false)


# Kernel update triggers zypper purge-kernels and lock after reboot.
- 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'
- sap_general_preconfigure_reboot_ok | d(false)
changed_when: false


- name: Let the role fail if a reboot is required
ansible.builtin.fail:
msg: Reboot is required!
listen: __sap_general_preconfigure_reboot_handler
when:
- sap_general_preconfigure_fail_if_reboot_required|d(true)
- not sap_general_preconfigure_reboot_ok|d(false)
- sap_general_preconfigure_fail_if_reboot_required | d(true)
- not sap_general_preconfigure_reboot_ok | d(false)

- name: Show a warning message if a reboot is required
ansible.builtin.debug:
msg: "WARN: Reboot is required!"
listen: __sap_general_preconfigure_reboot_handler
when:
- not sap_general_preconfigure_fail_if_reboot_required|d(true)
- not sap_general_preconfigure_reboot_ok|d(false)
- 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
2 changes: 1 addition & 1 deletion roles/sap_general_preconfigure/meta/argument_specs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ argument_specs:
sap_general_preconfigure_packages:
default: "{{ __sap_general_preconfigure_packages }}"
description:
- 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.
required: false
type: list
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# SPDX-License-Identifier: Apache-2.0
---

- name: Gather package facts again after the installation phase
ansible.builtin.package_facts:
tags:
- always

- name: Assert - List required SAP Notes
ansible.builtin.debug:
var: __sap_general_preconfigure_sapnotes_versions | difference([''])
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# SPDX-License-Identifier: Apache-2.0
---

- name: Gather package facts
ansible.builtin.package_facts:
tags:
- sap_general_preconfigure_installation

- name: Check enabled repos
when: sap_general_preconfigure_enable_repos
block:
Expand Down
5 changes: 5 additions & 0 deletions roles/sap_general_preconfigure/tasks/RedHat/configuration.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# SPDX-License-Identifier: Apache-2.0
---

- name: Gather package facts again after the installation phase
ansible.builtin.package_facts:
tags:
- always

- name: Configure - List required SAP Notes
ansible.builtin.debug:
var: __sap_general_preconfigure_sapnotes_versions | difference([''])
Expand Down
5 changes: 5 additions & 0 deletions roles/sap_general_preconfigure/tasks/RedHat/installation.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# SPDX-License-Identifier: Apache-2.0
---

- name: Gather package facts
ansible.builtin.package_facts:
tags:
- sap_general_preconfigure_installation

- name: Perform steps for enabling required repos
when: sap_general_preconfigure_enable_repos
block:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@

- name: Assert - Include configuration actions for required sapnotes
ansible.builtin.include_tasks: "sapnote/assert-{{ sap_note_line_item.number }}.yml"
with_items: "{{ __sap_general_preconfigure_sapnotes_versions | difference(['']) }}"
loop: "{{ __sap_general_preconfigure_sapnotes_versions | difference(['']) }}"
loop_control:
loop_var: sap_note_line_item
Loading
Loading