Blob Blame History Raw
commit ecb7c33e9a8eddb633189d332683309d398fd54f
Author: Bernd Finger <bfinger@redhat.com>
Date:   Fri Jun 19 19:27:48 2020 +0200

    - replaced yum package update by Jinja2
    - added minimum required kernel versions for RHEL 8

diff --git a/tasks/RedHat/installation.yml b/tasks/RedHat/installation.yml
index 7995d99..9ba248c 100644
--- a/tasks/RedHat/installation.yml
+++ b/tasks/RedHat/installation.yml
@@ -71,44 +71,71 @@
 
 - name: Ensure minimum packages are installed
   block:
-    - name: check if minimum release needs to be installed
-      shell: |
-        set -x
-        required_pkg={{ pkg | join('-') }}
-#        newest=$(echo -e "$required_pkg\n$(rpm -q {{ pkg[0] }} )"| sort -V | tail -1)
-        newest=$(echo -e "$required_pkg\n$(rpm -q {{ pkg[0] }} )"| awk '{gsub ("\\.el", ".0.0."); print}' | sort -V | tail -1)
-#        if [ $newest == $required_pkg ]; then
-        if [ $newest == ${required_pkg/.el/.0.0.} ]; then
-           echo $newest
-        fi
-      loop: "{{ sap_hana_preconfigure_min_pkgs }}"
-      loop_control:
-        loop_var: pkg
-      check_mode: no
-      register: sap_hana_preconfigure_register_minpkglist
-      changed_when: false
-
-    - name: Initialize an empty list for our strings
-      set_fact:
-        sap_hana_preconfigure_fact_minpkglist: []
-
-    - name: Create list of packages to be installed
-      set_fact:
-        sap_hana_preconfigure_fact_minpkglist: "{{ sap_hana_preconfigure_fact_minpkglist | difference(['']) + [ pkg.stdout ] }}"
-      loop: "{{ sap_hana_preconfigure_register_minpkglist.results }}"
-      loop_control:
-        loop_var: pkg
-    - debug: var=sap_hana_preconfigure_fact_minpkglist
-
-    - name: Install minimum packages if required
-      yum:
-        name: "{{  sap_hana_preconfigure_fact_minpkglist }}"
-        state: present
-      when: not ( sap_hana_preconfigure_fact_minpkglist == [ "" ] )
+  - name: Gather package facts
+    package_facts:
+
+  - set_fact:
+      reqpkgs: "{{ __sap_hana_preconfigure_min_pkgs }}"
+
+  - debug:
+      var: reqpkgs
+
+  - set_fact:
+      sap_hana_preconfigure_fact_minpkglist: |-
+        {% set ns = namespace() %}
+        {% set ns.pkgs = [] %}
+        {% for reqpkg in reqpkgs %}
+        {%   if not reqpkg[0] in ansible_facts.packages %}
+        {%     set _ = ns.pkgs.append(reqpkg | join('-')) %}
+        {%   else %}
+        {%     set pkg = ansible_facts.packages[reqpkg[0]][-1] %}
+        {%     set verrel = pkg.version ~ '-' ~ pkg.release %}
+        {%     if reqpkg[1].replace (".el", ".0.0.") is version(verrel.replace (".el", ".0.0."), '>', strict=false) %}
+        {%       set _ = ns.pkgs.append(reqpkg | join('-')) %}
+        {%     else %}
+        {%       set _ = "pkg already installed with same or later version" %}
+        {%     endif %}
+        {%   endif %}
+        {% endfor %}
+        {{ ns.pkgs }}
+
+#    - name: check if minimum release needs to be installed
+#      shell: |
+#        set -x
+#        required_pkg={{ pkg | join('-') }}
+#        newest=$(echo -e "$required_pkg\n$(rpm -q {{ pkg[0] }} )"| sed "s,\.el,.0.0.," | sort -V | tail -1)
+#        if [ $newest == ${required_pkg/.el/.0.0.} ]; then
+#           echo $newest
+#        fi
+#      loop: "{{ __sap_hana_preconfigure_min_pkgs }}"
+#      loop_control:
+#        loop_var: pkg
+#      check_mode: no
+#      register: sap_hana_preconfigure_register_minpkglist
+#      changed_when: false
+
+#    - name: Initialize an empty list for our strings
+#      set_fact:
+#        sap_hana_preconfigure_fact_minpkglist: []
+
+#    - name: Create list of packages to be installed
+#      set_fact:
+#        sap_hana_preconfigure_fact_minpkglist: "{{ sap_hana_preconfigure_fact_minpkglist | difference(['']) + [ pkg.stdout ] }}"
+#      loop: "{{ sap_hana_preconfigure_register_minpkglist.results }}"
+#      loop_control:
+#        loop_var: pkg
+
+  - debug: var=sap_hana_preconfigure_fact_minpkglist
+
+  - name: Install minimum packages if required
+    yum:
+      name: "{{ sap_hana_preconfigure_fact_minpkglist }}"
+      state: present
+    when: not ( sap_hana_preconfigure_fact_minpkglist == [ "" ] )
 
   when: 
     - sap_hana_preconfigure_min_package_check|bool
-    - not( (sap_hana_preconfigure_min_pkgs is undefined) or (sap_hana_preconfigure_min_pkgs is none) or (sap_hana_preconfigure_min_pkgs | trim == '') ) 
+    - not( (__sap_hana_preconfigure_min_pkgs is undefined) or (__sap_hana_preconfigure_min_pkgs is none) or (__sap_hana_preconfigure_min_pkgs | trim == '') ) 
 
 - set_fact:
     needs_restarting_command: "needs-restarting -r"
diff --git a/vars/RedHat_7.yml b/vars/RedHat_7.yml
index 30c6d38..8ac6939 100644
--- a/vars/RedHat_7.yml
+++ b/vars/RedHat_7.yml
@@ -44,40 +44,40 @@ __sap_hana_preconfigure_required_ppc64le:
   - IBMinvscout
 
 # In SAP Note 2235581, certain minimal required packages for the different RHEL 7 minor releases are listed.
-# The following will assign them properly to __sap_hana_preconfigure_min_packages.
-# If variable __sap_hana_preconfigure_min_packages_VERSION is not defined, __sap_hana_preconfigure_min_packages will be undefined as well.
+# The following will assign them properly to __sap_hana_preconfigure_min_pkgs.
+# If variable __sap_hana_preconfigure_min_packages_VERSION is not defined,
+# variable __sap_hana_preconfigure_min_pkgs will be undefined as well.
 
-__sap_hana_preconfigure_min_packages_7.2:
+__sap_hana_preconfigure_min_packages_7_2:
   - [ 'kernel' , '3.10.0-327.62.4.el7' ]
   - [ 'systemd' , '219-19.el7_2.4' ]
 
-__sap_hana_preconfigure_min_packages_7.3:
+__sap_hana_preconfigure_min_packages_7_3:
   - [ 'kernel' , '3.10.0-514.36.5.el7' ]
   - [ 'glibc' , '2.17-157.el7_3.5' ]
   - [ 'tuned-profiles-sap-hana' , '2.7.1-3.el7_3.3' ]
 
-__sap_hana_preconfigure_min_packages_7.4:
+__sap_hana_preconfigure_min_packages_7_4:
   - [ 'kernel' , '3.10.0-693.11.6.el7' ]
   - [ 'tuned-profiles-sap-hana' , '2.8.0-5.el7_4.2' ]
 
 # SAP note 2812427:
-__sap_hana_preconfigure_min_packages_7.5:
+__sap_hana_preconfigure_min_packages_7_5:
   - [ 'kernel' , '3.10.0-862.41.1.el7' ]
 
 # SAP note 2812427:
-__sap_hana_preconfigure_min_packages_7.6:
+__sap_hana_preconfigure_min_packages_7_6:
   - [ 'kernel' , '3.10.0-957.27.4.el7' ]
 
 # SAP note 2812427:
-__sap_hana_preconfigure_min_packages_7.7:
+__sap_hana_preconfigure_min_packages_7_7:
   - [ 'kernel' , '3.10.0-1062.1.1.el7' ]
 
-# Empty definitions for upcoming RHEL 7 minor releases:
-__sap_hana_preconfigure_min_packages_7.8:
+__sap_hana_preconfigure_min_packages_7_8:
 
-__sap_hana_preconfigure_min_packages_7.9:
+__sap_hana_preconfigure_min_packages_7_9:
 
-__sap_hana_preconfigure_min_pkgs: "{{ lookup('vars','__sap_hana_preconfigure_min_packages_' + ansible_distribution_version|string ) }}"
+__sap_hana_preconfigure_min_pkgs: "{{ lookup('vars','__sap_hana_preconfigure_min_packages_' + ansible_distribution_version|string|replace (\".\", \"_\") ) }}"
 
 __sap_hana_preconfigure_packages:
 # SAP note 2009879:
diff --git a/vars/RedHat_8.yml b/vars/RedHat_8.yml
index 1ea7a88..3975dad 100644
--- a/vars/RedHat_8.yml
+++ b/vars/RedHat_8.yml
@@ -50,8 +50,52 @@ __sap_hana_preconfigure_required_ppc64le:
   - ppc64-diag
   - IBMinvscout
 
-# Minimum required package levels for RHEL 8:
-__sap_hana_preconfigure_min_packages_8:
+# In SAP Note 2777782, certain minimal required packages for the different RHEL 8 minor releases are listed.
+# The following will assign them properly to __sap_hana_preconfigure_min_pkgs.
+# If variable __sap_hana_preconfigure_min_packages_VERSION_ARCH is not defined,
+# variable __sap_hana_preconfigure_min_pkgs will be undefined as well.
+
+# Minimum required package levels for RHEL 8.0:
+__sap_hana_preconfigure_min_packages_8_0_x86_64:
+
+__sap_hana_preconfigure_min_packages_8_0_ppc64le:
+  - [ 'kernel' , '4.18.0-80.15.1.el8_0' ]
+
+__sap_hana_preconfigure_min_packages_8_1_x86_64:
+  - [ 'kernel' , '4.18.0-147.5.1.el8_1' ]
+
+__sap_hana_preconfigure_min_packages_8_1_ppc64le:
+  - [ 'kernel' , '4.18.0-147.5.1.el8_1' ]
+
+__sap_hana_preconfigure_min_packages_8_2_x86_64:
+
+__sap_hana_preconfigure_min_packages_8_2_ppc64le:
+
+__sap_hana_preconfigure_min_packages_8_3_x86_64:
+
+__sap_hana_preconfigure_min_packages_8_3_ppc64le:
+
+__sap_hana_preconfigure_min_packages_8_4_x86_64:
+
+__sap_hana_preconfigure_min_packages_8_4_ppc64le:
+
+__sap_hana_preconfigure_min_packages_8_5_x86_64:
+
+__sap_hana_preconfigure_min_packages_8_5_ppc64le:
+
+__sap_hana_preconfigure_min_packages_8_6_x86_64:
+
+__sap_hana_preconfigure_min_packages_8_6_ppc64le:
+
+__sap_hana_preconfigure_min_packages_8_7_x86_64:
+
+__sap_hana_preconfigure_min_packages_8_7_ppc64le:
+
+__sap_hana_preconfigure_min_packages_8_8_x86_64:
+
+__sap_hana_preconfigure_min_packages_8_8_ppc64le:
+
+__sap_hana_preconfigure_min_pkgs: "{{ lookup('vars','__sap_hana_preconfigure_min_packages_' + ansible_distribution_version|string|replace (\".\", \"_\") + '_' + ansible_architecture) }}"
 
 __sap_hana_preconfigure_packages:
 # SAP NOTE 2772999: