mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 00:55:19 +00:00
Merge pull request #37736 from dhaines/issue-37732
handle semodule version >=2.4 (#37732) and fix typo
This commit is contained in:
commit
371b0a86d9
@ -240,9 +240,29 @@ def list_semod():
|
||||
|
||||
.. versionadded:: 2016.3.0
|
||||
'''
|
||||
helptext = __salt__['cmd.run']('semodule -h').splitlines()
|
||||
semodule_version = ''
|
||||
for line in helptext:
|
||||
if line.strip().startswith('full'):
|
||||
semodule_version = 'new'
|
||||
|
||||
if semodule_version == 'new':
|
||||
mdata = __salt__['cmd.run']('semodule -lfull').splitlines()
|
||||
ret = {}
|
||||
for line in mdata:
|
||||
if not line.strip():
|
||||
continue
|
||||
comps = line.split()
|
||||
if len(comps) == 4:
|
||||
ret[comps[1]] = {'Enabled': False,
|
||||
'Version': None}
|
||||
else:
|
||||
ret[comps[1]] = {'Enabled': True,
|
||||
'Version': None}
|
||||
else:
|
||||
mdata = __salt__['cmd.run']('semodule -l').splitlines()
|
||||
ret = {}
|
||||
for line in mdata[1:]:
|
||||
for line in mdata:
|
||||
if not line.strip():
|
||||
continue
|
||||
comps = line.split()
|
||||
|
@ -198,7 +198,8 @@ def module(name, module_state='Enabled', version='any'):
|
||||
installed_version = modules[name]['Version']
|
||||
if not installed_version == version:
|
||||
ret['comment'] = 'Module version is {0} and does not match ' \
|
||||
'the desired version of {1}'.format(installed_version, version)
|
||||
'the desired version of {1} or you are ' \
|
||||
'using semodule >= 2.4'.format(installed_version, version)
|
||||
ret['result'] = False
|
||||
return ret
|
||||
current_module_state = _refine_module_state(modules[name]['Enabled'])
|
||||
@ -207,7 +208,7 @@ def module(name, module_state='Enabled', version='any'):
|
||||
return ret
|
||||
if __opts__['test']:
|
||||
ret['result'] = None
|
||||
ret['comment'] = 'Module {0} is set to be togggled to {1}'.format(
|
||||
ret['comment'] = 'Module {0} is set to be toggled to {1}'.format(
|
||||
name, module_state)
|
||||
return ret
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user