

def persist(name, value, config=None):
    "\n    Assign and persist a simple sysctl parameter for this minion. If ``config``\n    is not specified, a sensible default will be chosen using\n    :mod:`sysctl.default_config <salt.modules.linux_sysctl.default_config>`.\n\n    CLI Example:\n\n    .. code-block:: bash\n\n        salt '*' sysctl.persist net.ipv4.ip_forward 1\n    "
    if (config is None):
        config = default_config()
    running = show()
    edited = False
    if (not os.path.isfile(config)):
        try:
            with salt.utils.fopen(config, 'w+') as _fh:
                _fh.write('#\n# Kernel sysctl configuration\n#\n')
        except (IOError, OSError):
            msg = 'Could not write to file: {0}'
            raise CommandExecutionError(msg.format(config))
    nlines = []
    try:
        with salt.utils.fopen(config, 'r') as _fh:
            config_data = _fh.readlines()
    except (IOError, OSError):
        msg = 'Could not read from file: {0}'
        raise CommandExecutionError(msg.format(config))
    for line in config_data:
        if line.startswith('#'):
            nlines.append(line)
            continue
        if ('=' not in line):
            nlines.append(line)
            continue
        comps = [i.strip() for i in line.split('=', 1)]
        if (isinstance(comps[1], string_types) and (' ' in comps[1])):
            comps[1] = re.sub('\\s+', '\t', comps[1])
        if (isinstance(value, string_types) and (' ' in value)):
            value = re.sub('\\s+', '\t', value)
        if (len(comps) < 2):
            nlines.append(line)
            continue
        if (name == comps[0]):
            if (str(comps[1]) == str(value)):
                if (name in running):
                    if (str(running[name]) != str(value)):
                        assign(name, value)
                        return 'Updated'
                return 'Already set'
            nlines.append('{0} = {1}\n'.format(name, value))
            edited = True
            continue
        else:
            nlines.append(line)
    if (not edited):
        nlines.append('{0} = {1}\n'.format(msg, value))
    try:
        with salt.utils.fopen(config, 'w+') as _fh:
            _fh.writelines(nlines)
    except (IOError, OSError):
        msg = 'Could not write to file: {0}'
        raise CommandExecutionError(msg.format(config))
    assign(name, value)
    return 'Updated'

dataset/ETHPy150Open saltstack/salt/salt/modules/linux_sysctl.py persist/VarMisuse@463/736 `name`->`msg`