File fix-for-suse-expanded-support-detection.patch of Package salt.10902

From 8e1264d4002b9e084cb48ce6977c01dbf4687592 Mon Sep 17 00:00:00 2001
From: Jochen Breuer <jbreuer@suse.de>
Date: Thu, 6 Sep 2018 17:15:18 +0200
Subject: [PATCH] Fix for SUSE Expanded Support detection

A SUSE ES installation has both, the centos-release and redhat-release
file. Since os_data only used the centos-release file to detect a
CentOS installation, this lead to SUSE ES being detected as CentOS.

This change also adds a check for redhat-release and then marks the
'lsb_distrib_id' as RedHat.
---
 salt/grains/core.py | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/salt/grains/core.py b/salt/grains/core.py
index cd9ba1f29c..c9b3a4e394 100644
--- a/salt/grains/core.py
+++ b/salt/grains/core.py
@@ -1595,8 +1595,17 @@ def os_data():
                                 grains['lsb_distrib_codename'] = \
                                     comps[3].replace('(', '').replace(')', '')
                 elif os.path.isfile('/etc/centos-release'):
-                    # CentOS Linux
-                    grains['lsb_distrib_id'] = 'CentOS'
+                    log.trace('Parsing distrib info from /etc/centos-release')
+                    # Maybe CentOS Linux; could also be SUSE Expanded Support.
+                    # SUSE ES has both, centos-release and redhat-release.
+                    if os.path.isfile('/etc/redhat-release'):
+                        with salt.utils.files.fopen('/etc/redhat-release') as ifile:
+                            for line in ifile:
+                                if "red hat enterprise linux server" in line.lower():
+                                    # This is a SUSE Expanded Support Rhel installation
+                                    grains['lsb_distrib_id'] = 'RedHat'
+                                    break
+                    grains.setdefault('lsb_distrib_id', 'CentOS')
                     with salt.utils.files.fopen('/etc/centos-release') as ifile:
                         for line in ifile:
                             # Need to pull out the version and codename
-- 
2.18.0


openSUSE Build Service is sponsored by