mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 17:09:03 +00:00
Merge branch 'sysctl-fixes' of https://github.com/oldmantaiter/salt into oldmantaiter-sysctl-fixes
Conflicts: salt/modules/netbsd_sysctl.py
This commit is contained in:
commit
df06a1bd3c
@ -22,7 +22,7 @@ def __virtual__():
|
||||
return __virtualname__ if __grains__['os'] == 'MacOS' else False
|
||||
|
||||
|
||||
def show():
|
||||
def show(config_file=False):
|
||||
'''
|
||||
Return a list of sysctl parameters for this minion
|
||||
|
||||
|
@ -26,7 +26,7 @@ def _formatfor(name, value, config, tail=''):
|
||||
return '{0}={1}{2}'.format(name, value, tail)
|
||||
|
||||
|
||||
def show():
|
||||
def show(config_file=False):
|
||||
'''
|
||||
Return a list of sysctl parameters for this minion
|
||||
|
||||
|
@ -35,7 +35,7 @@ def __virtual__():
|
||||
return __virtualname__
|
||||
|
||||
|
||||
def default_config():
|
||||
def default_config(config):
|
||||
'''
|
||||
Linux hosts using systemd 207 or later ignore ``/etc/sysctl.conf`` and only
|
||||
load from ``/etc/sysctl.d/*.conf``. This function will do the proper checks
|
||||
@ -82,9 +82,8 @@ def show(config_file=False):
|
||||
'''
|
||||
ret = {}
|
||||
if config_file:
|
||||
config_file_path = default_config()
|
||||
try:
|
||||
for line in salt.utils.fopen(config_file_path):
|
||||
for line in salt.utils.fopen(config_file):
|
||||
if not line.startswith('#') and '=' in line:
|
||||
# search if we have some '=' instead of ' = ' separators
|
||||
SPLIT = ' = '
|
||||
@ -94,7 +93,7 @@ def show(config_file=False):
|
||||
key = key.strip()
|
||||
value = value.lstrip()
|
||||
ret[key] = value
|
||||
except OSError:
|
||||
except OSError, IOError:
|
||||
log.error('Could not open sysctl file')
|
||||
return None
|
||||
else:
|
||||
|
@ -21,7 +21,7 @@ def __virtual__():
|
||||
return __virtualname__ if __grains__['os'] == 'NetBSD' else False
|
||||
|
||||
|
||||
def show():
|
||||
def show(config_file=False):
|
||||
'''
|
||||
Return a list of sysctl parameters for this minion
|
||||
|
||||
|
@ -20,7 +20,7 @@ def __virtual__():
|
||||
return __virtualname__ if __grains__['os'] == 'OpenBSD' else False
|
||||
|
||||
|
||||
def show():
|
||||
def show(config_file=False):
|
||||
'''
|
||||
Return a list of sysctl parameters for this minion
|
||||
|
||||
|
@ -53,9 +53,15 @@ def present(name, value, config=None):
|
||||
else:
|
||||
config = '/etc/sysctl.conf'
|
||||
|
||||
current = __salt__['sysctl.show']()
|
||||
configured = __salt__['sysctl.show'](config_file=True)
|
||||
if __opts__['test']:
|
||||
current = __salt__['sysctl.show']()
|
||||
configured = __salt__['sysctl.show'](config_file=config)
|
||||
if not configured:
|
||||
ret['result'] = None
|
||||
ret['comment'] = (
|
||||
'Sysctl option {0} might be changed, we failed to check config file at {1}.\n'
|
||||
'The file is either unreadable, or missing.').format(name, config)
|
||||
return ret
|
||||
if name in current and name not in configured:
|
||||
if re.sub(' +|\t+', ' ', current[name]) != re.sub(' +|\t+', ' ', str(value)):
|
||||
ret['result'] = None
|
||||
|
Loading…
Reference in New Issue
Block a user