mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Merge pull request #32165 from terminalmage/issue31731
Make __virtual__ for rhservice.py more robust
This commit is contained in:
commit
ae472617af
1 changed files with 13 additions and 9 deletions
|
@ -67,18 +67,22 @@ def __virtual__():
|
|||
else:
|
||||
return (False, 'Cannot load rh_service module on SUSE > 11')
|
||||
|
||||
try:
|
||||
osrelease = float(__grains__.get('osrelease', 0))
|
||||
except ValueError:
|
||||
return (False, 'Cannot load rh_service module: '
|
||||
'osrelease grain, {0}, not a float,'.format(osrelease))
|
||||
osrelease_major = __grains__.get('osrelease_info', [0])[0]
|
||||
|
||||
if __grains__['os'] == 'Fedora':
|
||||
if osrelease > 15:
|
||||
return (False, 'Cannot load rh_service module on Fedora >= 15')
|
||||
if osrelease_major >= 15:
|
||||
return (
|
||||
False,
|
||||
'Fedora >= 15 uses systemd, will not load rh_service.py '
|
||||
'as virtual \'service\''
|
||||
)
|
||||
if __grains__['os'] in ('RedHat', 'CentOS', 'ScientificLinux', 'OEL'):
|
||||
if osrelease >= 7:
|
||||
return (False, 'Cannot load rh_service module on RedHat >= 7')
|
||||
if osrelease_major >= 7:
|
||||
return (
|
||||
False,
|
||||
'RedHat-based distros >= version 7 use systemd, will not '
|
||||
'load rh_service.py as virtual \'service\''
|
||||
)
|
||||
return __virtualname__
|
||||
return (False, 'Cannot load rh_service module: OS not in {0}'.format(enable))
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue