def persist(name, value, config='/etc/sysctl.conf'):
    '''
    Assign and persist a simple sysctl parameter for this minion

    CLI Example:

    .. code-block:: bash

        salt '*' sysctl.persist net.inet.ip.forwarding 1
    '''
    nlines = []
    edited = False
    value = str(value)

    # create /etc/sysctl.conf if not present
    if not os.path.isfile(config):
        try:
            salt.utils.fopen(config, 'w+').close()
        except (__HOLE__, OSError):
            msg = 'Could not create {0}'
            raise CommandExecutionError(msg.format(config))

    with salt.utils.fopen(config, 'r') as ifile:
        for line in ifile:
            if not line.startswith('{0}='.format(name)):
                nlines.append(line)
                continue
            else:
                key, rest = line.split('=', 1)
                if rest.startswith('"'):
                    _, rest_v, rest = rest.split('"', 2)
                elif rest.startswith('\''):
                    _, rest_v, rest = rest.split('\'', 2)
                else:
                    rest_v = rest.split()[0]
                    rest = rest[len(rest_v):]
                if rest_v == value:
                    return 'Already set'
                new_line = '{0}={1}{2}'.format(key, value, rest)
                nlines.append(new_line)
                edited = True
    if not edited:
        nlines.append('{0}={1}\n'.format(name, value))
    with salt.utils.fopen(config, 'w+') as ofile:
        ofile.writelines(nlines)

    assign(name, value)
    return 'Updated'
dataset/ETHPy150Open saltstack/salt/salt/modules/openbsd_sysctl.py/persist