

def assign(name, value):
    "\n    Assign a single sysctl parameter for this minion\n\n    CLI Example:\n\n    .. code-block:: bash\n\n        salt '*' sysctl.assign net.ipv4.ip_forward 1\n    "
    value = str(value)
    trantab = (''.maketrans('./', '/.') if six.PY3 else string.maketrans('./', '/.'))
    sysctl_file = '/proc/sys/{0}'.format(name.translate(trantab))
    if (not os.path.exists(sysctl_file)):
        raise CommandExecutionError('sysctl {0} does not exist'.format(name))
    ret = {
        
    }
    cmd = 'sysctl -w {0}="{1}"'.format(name, value)
    data = __salt__['cmd.run_all'](cmd, python_shell=False)
    out = data['stdout']
    err = data['stderr']
    regex = re.compile('^{0}\\s+=\\s+{1}$'.format(re.escape(name), re.escape(value)))
    if ((not regex.match(out)) or ('Invalid argument' in str(err))):
        if ((data['retcode'] != 0) and err):
            error = err
        else:
            error = out
        raise CommandExecutionError('sysctl -w failed: {0}'.format(error))
    (new_name, new_value) = out.split(' = ', 1)
    ret[new_name] = new_value
    return ret

dataset/ETHPy150Open saltstack/salt/salt/modules/linux_sysctl.py assign/original