Skip to content
This repository has been archived by the owner on Mar 23, 2023. It is now read-only.

Commit

Permalink
Merge pull request #215 from berndfinger/master
Browse files Browse the repository at this point in the history
Sync to upstream after QA has passed successfully
  • Loading branch information
berndfinger authored Jan 11, 2022
2 parents f290f3b + bfb865b commit 91d63ee
Show file tree
Hide file tree
Showing 137 changed files with 887 additions and 1,630 deletions.
20 changes: 20 additions & 0 deletions .ansible-lint
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
skip_list:
# We do not intend to change the role name
- role-name
- ignore-errors # We use ignore_errors for all the assert tasks, which should be acceptable

exclude_paths:
- tasks/SLES
- tasks/SLES15
- tasks/sapnote/1275776 # SLES - sapconf, saptune, etc
- tasks/sapnote/1944799 # SLES - HANA install and config guidelines
- tasks/sapnote/2013638.yml # RHEL 6.5 - OS settings
- tasks/sapnote/2136965.yml # RHEL 6.6 - OS settings
- tasks/sapnote/2247020.yml # RHEL 6.7 - OS settings
- tasks/sapnote/2578899 # SLES 15 - installation
- tasks/sapnote/2684254 # SLES 15 - OS settings for HANA
- vars/RedHat_6.5.yml
- vars/RedHat_6.6.yml
- vars/RedHat_6.7.yml
- vars/SLES_15.yml
20 changes: 20 additions & 0 deletions .github/workflows/ansible-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Ansible Lint

on: [push, pull_request]

jobs:
ansible-lint:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Lint Ansible Playbook
uses: ansible/ansible-lint-action@master
with:
targets: |
./
override-deps: |
ansible-core==2.12
ansible-lint==5.3.0
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
*.swp
*.retry

.cache/
21 changes: 21 additions & 0 deletions .yamllint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
# Based on ansible-lint config
extends: default

rules:
braces: {max-spaces-inside: 1, level: error}
brackets: {max-spaces-inside: 1, level: error}
# colons: {max-spaces-after: -1, level: error}
# commas: {max-spaces-after: -1, level: error}
comments: disable
comments-indentation: disable
# document-start: disable
# empty-lines: {max: 3, level: error}
# hyphens: {level: error}
# indentation: disable
# key-duplicates: enable
line-length: disable
# new-line-at-end-of-file: disable
# new-lines: {type: unix}
# trailing-spaces: disable
truthy: disable
18 changes: 9 additions & 9 deletions defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
######################################
# HANA Default Variables
# HANA Default Variables
#

# Want extensive debugging
Expand Down Expand Up @@ -46,19 +46,19 @@ sap_hana_preconfigure_supported_rhel_minor_releases: "{{ __sap_hana_preconfigure
sap_hana_preconfigure_enable_sap_hana_repos: no

# Change one or more of the following in case you want different repos to be enabled than defined in vars.
sap_hana_preconfigure_req_repos_RedHat_7_x86_64: "{{ __sap_hana_preconfigure_req_repos_RedHat_7_x86_64 }}"
sap_hana_preconfigure_req_repos_RedHat_7_ppc64le: "{{ __sap_hana_preconfigure_req_repos_RedHat_7_ppc64le }}"
sap_hana_preconfigure_req_repos_RedHat_8_x86_64: "{{ __sap_hana_preconfigure_req_repos_RedHat_8_x86_64 }}"
sap_hana_preconfigure_req_repos_RedHat_8_ppc64le: "{{ __sap_hana_preconfigure_req_repos_RedHat_8_ppc64le }}"
sap_hana_preconfigure_req_repos_RedHat_9_x86_64: "{{ __sap_hana_preconfigure_req_repos_RedHat_9_x86_64 }}"
sap_hana_preconfigure_req_repos_RedHat_9_ppc64le: "{{ __sap_hana_preconfigure_req_repos_RedHat_9_ppc64le }}"
sap_hana_preconfigure_req_repos_redhat_7_x86_64: "{{ __sap_hana_preconfigure_req_repos_redhat_7_x86_64 }}"
sap_hana_preconfigure_req_repos_redhat_7_ppc64le: "{{ __sap_hana_preconfigure_req_repos_redhat_7_ppc64le }}"
sap_hana_preconfigure_req_repos_redhat_8_x86_64: "{{ __sap_hana_preconfigure_req_repos_redhat_8_x86_64 }}"
sap_hana_preconfigure_req_repos_redhat_8_ppc64le: "{{ __sap_hana_preconfigure_req_repos_redhat_8_ppc64le }}"
sap_hana_preconfigure_req_repos_redhat_9_x86_64: "{{ __sap_hana_preconfigure_req_repos_redhat_9_x86_64 }}"
sap_hana_preconfigure_req_repos_redhat_9_ppc64le: "{{ __sap_hana_preconfigure_req_repos_redhat_9_ppc64le }}"

# Set to "yes" if you want the role to set the RHEL minor release, which is required for SAP HANA. Default is "no".
sap_hana_preconfigure_set_minor_release: no

# HANA Major and minor version
# These variables are used in other SAP HANA related roles, e.g. sap-hana-mediacheck.
sap_hana_version: "2"
sap_hana_version: "2"
sap_hana_sps: "0"

# List of RHEL packages to be installed for SAP HANA. For RHEL 8 and later, you can choose to install either the default list
Expand Down Expand Up @@ -115,7 +115,7 @@ sap_hana_preconfigure_ibm_power_repo_url: "{{ __sap_hana_preconfigure_ibm_power_
## defaults to empty
#sap_hana_preconfigure_ppcle_mtu9000_if: "{{ ansible_interfaces| difference(['lo']) }}" # all interfaces
sap_hana_preconfigure_ppcle_mtu9000_if: ''
## list where tso flag should be set
## list where tso flag should be set
## defaults to all interfaces
sap_hana_preconfigure_ppcle_tso_if: "{{ ansible_interfaces| difference(['lo']) }}"

Expand Down
9 changes: 6 additions & 3 deletions handlers/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
when:
- sap_hana_preconfigure_run_grub2_mkconfig|d(true)

- debug:
- name: Display stat of /sys/firmware/efi
debug:
var: __sap_hana_preconfigure_register_stat_sys_firmware_efi.stat.exists
listen: __sap_hana_preconfigure_regenerate_grub2_conf_handler
when:
Expand All @@ -24,7 +25,8 @@
- not __sap_hana_preconfigure_register_stat_sys_firmware_efi.stat.exists
- sap_hana_preconfigure_run_grub2_mkconfig|d(true)

- debug:
- name: BIOS - Display the output of grub2-mkconfig
debug:
var: __sap_hana_preconfigure_register_grub2_mkconfig_bios_mode.stdout_lines,
__sap_hana_preconfigure_register_grub2_mkconfig_bios_mode.stderr_lines
listen: __sap_hana_preconfigure_regenerate_grub2_conf_handler
Expand All @@ -41,7 +43,8 @@
- __sap_hana_preconfigure_register_stat_sys_firmware_efi.stat.exists
- sap_hana_preconfigure_run_grub2_mkconfig|d(true)

- debug:
- name: UEFI - Display the output of grub2-mkconfig
debug:
var: __sap_hana_preconfigure_register_grub2_mkconfig_uefi_mode.stdout_lines,
__sap_hana_preconfigure_register_grub2_mkconfig_uefi_mode.stderr_lines
listen: __sap_hana_preconfigure_regenerate_grub2_conf_handler
Expand Down
20 changes: 9 additions & 11 deletions meta/main.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
---
galaxy_info:
author: Markus Koch, Thomas Bludau, Bernd Finger <[email protected]>, Than Ngo <[email protected]>
description: Configures a RHEL OS to be ready for SAP HANA installation
license: GNU General Public License v3.0
author: Markus Koch, Thomas Bludau, Bernd Finger, Than Ngo
description: Performs SAP HANA specific preparation steps on a RHEL system
company: Red Hat, Inc.
license: Apache
min_ansible_version: 2.9
platforms:
- name: EL
versions: [ 6, 7, 8 ]

galaxy_tags: [ 'system', 'sap', 'hana', 'beta' ]

dependencies: []
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.
- name: EL
versions: [ 7, 8 ]
galaxy_tags: [ 'sap', 'hana', 'rhel' ]
dependencies: []
2 changes: 2 additions & 0 deletions meta/runtime.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
requires_ansible: '>=2.9.10'
8 changes: 2 additions & 6 deletions tasks/RedHat/assert-configuration.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
---

#- name: Enable Debugging
# debug:
# verbosity: "{{ debuglevel }}"
#
- name: List required SAP Notes
- name: Assert - List required SAP Notes
debug:
var: __sap_hana_preconfigure_sapnotes_versions | difference([''])

- name: Gather service facts
service_facts:

- name: Include configuration actions for required sapnotes
- name: Assert - Include configuration actions for required sapnotes
include_tasks: "sapnote/assert-{{ sap_note_line_item.number }}.yml"
with_items: "{{ __sap_hana_preconfigure_sapnotes_versions | difference(['']) }}"
loop_control:
Expand Down
75 changes: 41 additions & 34 deletions tasks/RedHat/assert-installation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@
when: not sap_hana_preconfigure_min_rhel_release_check

# repos required for SAP HANA on RHEL 7 and RHEL 8:
- set_fact:
__sap_hana_preconfigure_required_repos: "{{ lookup('vars','__sap_hana_preconfigure_req_repos_RedHat_' +
- name: Fill the variable for the generic list of required repos
set_fact:
__sap_hana_preconfigure_required_repos: "{{ lookup('vars','__sap_hana_preconfigure_req_repos_redhat_' +
ansible_distribution_version|string|replace (\".\", \"_\") + '_' + ansible_architecture|string) }}"

- name: Get info about enabled repos
shell: subscription-manager repos --list-enabled | awk '/Repo ID:/{print $NF}'
shell: set -o pipefail && subscription-manager repos --list-enabled | awk '/Repo ID:/{print $NF}'
register: __sap_hana_preconfigure_register_enabled_repos_assert
changed_when: no

Expand All @@ -38,15 +39,16 @@
ignore_errors: "{{ sap_hana_preconfigure_assert_ignore_errors|d(false) }}"

- name: Detect if and how the minor RHEL release is set
shell: subscription-manager release | awk 'NF==2{printf $NF}NF!=2{print}'
shell: set -o pipefail && subscription-manager release | awk 'NF==2{printf $NF}NF!=2{print}'
register: __sap_hana_preconfigure_register_subscription_manager_release_assert
changed_when: no
ignore_errors: yes

- debug:
- name: Display the output of the subscription-manager release command
debug:
var: __sap_hana_preconfigure_register_subscription_manager_release_assert

- name: Assert that the RHEL version is locked correctly
- name: Assert that the RHEL release is locked correctly
assert:
that: "__sap_hana_preconfigure_register_subscription_manager_release_assert.stdout == '{{ ansible_distribution_version }}'"
fail_msg: "FAIL: The RHEL release lock status is '{{ __sap_hana_preconfigure_register_subscription_manager_release_assert.stdout }}'
Expand All @@ -55,7 +57,8 @@
ignore_errors: "{{ sap_hana_preconfigure_assert_ignore_errors|d(false) }}"
when: "ansible_distribution_version != '7.9'"

- debug:
- name: Report that checking the release lock is not necessary if the system is on RHEL 7.9
debug:
msg: "INFO: No need to check the release lock setting as the RHEL release {{ ansible_distribution_version }}
is the last RHEL {{ ansible_distribution_major_version }} minor release"
when: "ansible_distribution_version == '7.9'"
Expand All @@ -79,7 +82,7 @@
### # yum -y install ibm-power-managed-rhel7
###
- name: Get install status of required IBM packages
shell: yum info installed {{ __sap_hana_preconfigure_required_ppc64le | map('quote') | join(' ') }} | awk '/Name/{n=$NF}/Version/{v=$NF}/Release/{r=$NF}/Description/{printf ("%s\n", n)}'
shell: set -o pipefail && yum info installed {{ __sap_hana_preconfigure_required_ppc64le | map('quote') | join(' ') }} | awk '/Name/{n=$NF}/Version/{v=$NF}/Release/{r=$NF}/Description/{printf ("%s\n", n)}'
register: __sap_hana_preconfigure_register_required_ppc64le_packages_assert
changed_when: no
args:
Expand All @@ -99,7 +102,7 @@

- name: Minimum required package version check
block:
- name: Check if minimum required package versions are installed
- name: Assert - Create a list of minimum required package versions to be installed
# How does it work?
# 1 - Print the required package name and version with a prefix "1" followed by a space.
# 2 - In the same output sequence, list all installed versions of this package with a prefix "2" followed by a space.
Expand All @@ -116,7 +119,7 @@
# to be updated.
# 8 - case 2b: If the first column of the last line of the output is "2", it means that at least of the installed
# versions the package is equal to or greater than the required package version.
shell: |
shell: |
(echo "1 {{ pkg[0] }}-{{ pkg[1] }}";rpm -q --qf "%{NAME}-%{VERSION}-%{RELEASE}\n" {{ pkg[0] }} |
awk '{printf ("2 %s\n", $0)}') |
awk '{gsub ("\\.el", ".0.0"); print}' |
Expand All @@ -135,31 +138,32 @@
}
}
}'
with_list: "{{ __sap_hana_preconfigure_min_pkgs }}"
loop_control:
loop_var: pkg
check_mode: no
register: __sap_hana_preconfigure_register_minpkglist_assert
changed_when: no

- name: Assert that minimum required package versions are installed
with_list: "{{ __sap_hana_preconfigure_min_pkgs }}"
loop_control:
loop_var: pkg
check_mode: no
register: __sap_hana_preconfigure_register_minpkglist_assert
changed_when: no

- name: Assert that minimum required package versions are installed
# If the output includes the string "is already installed" (case 2b), we have a PASS. Otherwise, it's a FAIL.
assert:
that: "'is already installed' in line_item.stdout"
fail_msg: "FAIL: {{ line_item.stdout }}"
success_msg: "PASS: {{ line_item.stdout }}"
with_items: "{{ __sap_hana_preconfigure_register_minpkglist_assert.results }}"
loop_control:
loop_var: line_item
label: ""
ignore_errors: yes
assert:
that: "'is already installed' in line_item.stdout"
fail_msg: "FAIL: {{ line_item.stdout }}"
success_msg: "PASS: {{ line_item.stdout }}"
with_items: "{{ __sap_hana_preconfigure_register_minpkglist_assert.results }}"
loop_control:
loop_var: line_item
label: ""
ignore_errors: yes

when:
- sap_hana_preconfigure_min_package_check|bool
- __sap_hana_preconfigure_min_pkgs|d([])
- sap_hana_preconfigure_assert_ignore_errors|d(false)

- debug:
- name: Report if no minimum required package version is defined for this RHEL release
debug:
msg: "INFO: No minimum required package version defined (variable __sap_hana_preconfigure_min_pkgs)."
when: not __sap_hana_preconfigure_min_pkgs|d([])

Expand All @@ -180,18 +184,19 @@
ignore_errors: "{{ sap_hana_preconfigure_assert_ignore_errors|d(false) }}"
when: sap_hana_preconfigure_update

- debug:
- name: Report if checking for possible package updates is not requested
debug:
msg: "INFO: Not checking for possible package updates (variable sap_hana_preconfigure_update)."
when: not sap_hana_preconfigure_update

- name: "Set needs-restarting command in case of RHEL 7"
- name: "Assert - Set needs-restarting command in case of RHEL 7"
set_fact:
__sap_hana_preconfigure_fact_needs_restarting_command_assert: "needs-restarting -r"
when:
- ansible_os_family == 'RedHat'
- ansible_distribution_major_version == '7'

- name: "Set needs-restarting command in case of RHEL 8 or RHEL 9, except RHEL 8.0"
- name: "Assert - Set needs-restarting command in case of RHEL 8 or RHEL 9, except RHEL 8.0"
set_fact:
__sap_hana_preconfigure_fact_needs_restarting_command_assert: "yum needs-restarting -r"
when:
Expand All @@ -201,18 +206,20 @@
)
- ansible_distribution_version != '8.0'

- name: "Set customized needs-restarting command in case of RHEL 8.0"
- name: "Assert - Set customized needs-restarting command in case of RHEL 8.0"
set_fact:
__sap_hana_preconfigure_fact_needs_restarting_command_assert: "_IKRNL=$(rpm -q --last kernel | awk 'NR==1{sub(/kernel-/,\"\"); print $1}');
_CKRNL=$(uname -r); if [ ${_IKRNL} != ${_CKRNL} ]; then exit 1; else exit 0; fi"
when:
- ansible_os_family == 'RedHat'
- ansible_distribution_version == '8.0'

- debug:
- name: Assert - Display the command for checking a reboot requirement
debug:
var: __sap_hana_preconfigure_fact_needs_restarting_command_assert

- name: Check if system needs to be restarted
# Reason for noqa: The command to be executed might contain pipes
- name: Assert - Determine if system needs to be restarted # noqa command-instead-of-shell
shell: "{{ __sap_hana_preconfigure_fact_needs_restarting_command_assert }}"
register: __sap_hana_preconfigure_register_needs_restarting_assert
changed_when: false
Expand Down
14 changes: 2 additions & 12 deletions tasks/RedHat/configuration.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,10 @@
---

#- name: Enable Debugging
# debug:
# verbosity: "{{ debuglevel }}"
#
- name: List required SAP Notes
- name: Configure - List required SAP Notes
debug:
var: __sap_hana_preconfigure_sapnotes_versions | difference([''])

# We want to disable firewalld, so we need to check if firewalld is installed
# now in main.yml
#- name: Gather facts about installed packages
# package_facts:
# manager: auto

- name: Include configuration actions for required sapnotes
- name: Configure - Include configuration actions for required sapnotes
include_tasks: "sapnote/{{ sap_note_line_item.number }}.yml"
with_items: "{{ __sap_hana_preconfigure_sapnotes_versions | difference(['']) }}"
loop_control:
Expand Down
Loading

0 comments on commit 91d63ee

Please sign in to comment.