File fix-grain-for-os_family-on-suse-series.patch of Package salt

From db460c5b39d5a4ac6ee9620fbad47cb0dd1e328d Mon Sep 17 00:00:00 2001
From: Bo Maryniuk <bo@suse.de>
Date: Tue, 16 May 2017 14:42:07 +0200
Subject: [PATCH] Fix grain for os_family on SUSE series

---
 doc/topics/spm/spm_formula.rst       |  2 +-
 salt/modules/apache.py               |  2 +-
 salt/modules/inspectlib/collector.py |  6 +++---
 salt/modules/iptables.py             |  2 +-
 salt/modules/localemod.py            | 13 ++++++++++++-
 tests/integration/modules/pkg.py     |  2 +-
 6 files changed, 19 insertions(+), 8 deletions(-)

diff --git a/doc/topics/spm/spm_formula.rst b/doc/topics/spm/spm_formula.rst
index 2493527a22..aa53098e2e 100644
--- a/doc/topics/spm/spm_formula.rst
+++ b/doc/topics/spm/spm_formula.rst
@@ -11,7 +11,7 @@ describes the package. An example of this file is:
 
     name: apache
     os: RedHat, Debian, Ubuntu, SUSE, FreeBSD
-    os_family: RedHat, Debian, SUSE, FreeBSD
+    os_family: RedHat, Debian, Suse, FreeBSD
     version: 201506
     release: 2
     summary: Formula for installing Apache
diff --git a/salt/modules/apache.py b/salt/modules/apache.py
index 18bdab2726..2d7a79339c 100644
--- a/salt/modules/apache.py
+++ b/salt/modules/apache.py
@@ -52,7 +52,7 @@ def _detect_os():
     os_family = __grains__['os_family']
     if os_family == 'RedHat':
         return 'apachectl'
-    elif os_family == 'Debian' or os_family == 'SUSE':
+    elif os_family == 'Debian' or os_family == 'Suse':
         return 'apache2ctl'
     else:
         return 'apachectl'
diff --git a/salt/modules/inspectlib/collector.py b/salt/modules/inspectlib/collector.py
index 332c6efdec..b87a46b82f 100644
--- a/salt/modules/inspectlib/collector.py
+++ b/salt/modules/inspectlib/collector.py
@@ -87,7 +87,7 @@ class Inspector(EnvLoader):
         '''
         if self.grains_core.os_data().get('os_family') == 'Debian':
             return self.__get_cfg_pkgs_dpkg()
-        elif self.grains_core.os_data().get('os_family') in ['SUSE', 'redhat']:
+        elif self.grains_core.os_data().get('os_family') in ['Suse', 'redhat']:
             return self.__get_cfg_pkgs_rpm()
         else:
             return dict()
@@ -163,7 +163,7 @@ class Inspector(EnvLoader):
             if self.grains_core.os_data().get('os_family') == 'Debian':
                 cfg_data = salt.utils.to_str(self._syscall("dpkg", None, None, '--verify',
                                                            pkg_name)[0]).split(os.linesep)
-            elif self.grains_core.os_data().get('os_family') in ['SUSE', 'redhat']:
+            elif self.grains_core.os_data().get('os_family') in ['Suse', 'redhat']:
                 cfg_data = salt.utils.to_str(self._syscall("rpm", None, None, '-V', '--nodeps', '--nodigest',
                                                            '--nosignature', '--nomtime', '--nolinkto',
                                                            pkg_name)[0]).split(os.linesep)
@@ -240,7 +240,7 @@ class Inspector(EnvLoader):
         '''
         if self.grains_core.os_data().get('os_family') == 'Debian':
             return self.__get_managed_files_dpkg()
-        elif self.grains_core.os_data().get('os_family') in ['SUSE', 'redhat']:
+        elif self.grains_core.os_data().get('os_family') in ['Suse', 'redhat']:
             return self.__get_managed_files_rpm()
 
         return list(), list(), list()
diff --git a/salt/modules/iptables.py b/salt/modules/iptables.py
index 322553d285..b1823e891a 100644
--- a/salt/modules/iptables.py
+++ b/salt/modules/iptables.py
@@ -80,7 +80,7 @@ def _conf(family='ipv4'):
             return '/var/lib/ip6tables/rules-save'
         else:
             return '/var/lib/iptables/rules-save'
-    elif __grains__['os_family'] == 'SUSE':
+    elif __grains__['os_family'] == 'Suse':
         # SuSE does not seem to use separate files for IPv4 and IPv6
         return '/etc/sysconfig/scripts/SuSEfirewall2-custom'
     else:
diff --git a/salt/modules/localemod.py b/salt/modules/localemod.py
index ce83265544..e8eaf54573 100644
--- a/salt/modules/localemod.py
+++ b/salt/modules/localemod.py
@@ -135,6 +135,8 @@ def get_locale():
         return params.get('LANG', '')
     elif 'RedHat' in __grains__['os_family']:
         cmd = 'grep "^LANG=" /etc/sysconfig/i18n'
+    elif 'Suse' in __grains__['os_family']:
+        cmd = 'grep "^RC_LANG" /etc/sysconfig/language'
     elif 'Debian' in __grains__['os_family']:
         # this block only applies to Debian without systemd
         cmd = 'grep "^LANG=" /etc/default/locale'
@@ -183,6 +185,15 @@ def set_locale(locale):
             'LANG="{0}"'.format(locale),
             append_if_not_found=True
         )
+    elif 'Suse' in __grains__['os_family']:
+        if not __salt__['file.file_exists']('/etc/sysconfig/language'):
+            __salt__['file.touch']('/etc/sysconfig/language')
+        __salt__['file.replace'](
+            '/etc/sysconfig/language',
+            '^RC_LANG=.*',
+            'RC_LANG="{0}"'.format(locale),
+            append_if_not_found=True
+        )
     elif 'Debian' in __grains__['os_family']:
         # this block only applies to Debian without systemd
         update_locale = salt.utils.which('update-locale')
@@ -263,7 +274,7 @@ def gen_locale(locale, **kwargs):
     on_debian = __grains__.get('os') == 'Debian'
     on_ubuntu = __grains__.get('os') == 'Ubuntu'
     on_gentoo = __grains__.get('os_family') == 'Gentoo'
-    on_suse = __grains__.get('os_family') == 'SUSE'
+    on_suse = __grains__.get('os_family') == 'Suse'
     on_solaris = __grains__.get('os_family') == 'Solaris'
 
     if on_solaris:  # all locales are pre-generated
diff --git a/tests/integration/modules/pkg.py b/tests/integration/modules/pkg.py
index b24b32cb14..cdda2e0957 100644
--- a/tests/integration/modules/pkg.py
+++ b/tests/integration/modules/pkg.py
@@ -244,7 +244,7 @@ class PkgModuleTest(integration.ModuleCase,
             keys = ret.keys()
             self.assertIn('rpm', keys)
             self.assertIn('bash', keys)
-        elif os_family == 'SUSE':
+        elif os_family == 'Suse':
             ret = self.run_function(func, ['less', 'zypper'])
             keys = ret.keys()
             self.assertIn('less', keys)
-- 
2.17.1


openSUSE Build Service is sponsored by