

def add(name, uid=None, gid=None, groups=None, home=None, shell=None, unique=True, fullname='', roomnumber='', workphone='', homephone='', createhome=True, loginclass=None, **kwargs):
    "\n    Add a user to the minion\n\n    CLI Example:\n\n    .. code-block:: bash\n\n        salt '*' user.add name <uid> <gid> <groups> <home> <shell>\n    "
    kwargs = salt.utils.clean_kwargs(**kwargs)
    if salt.utils.is_true(kwargs.pop('system', False)):
        log.warning("pw_user module does not support the 'system' argument")
    if kwargs:
        log.warning('Invalid kwargs passed to user.add')
    if isinstance(groups, six.string_types):
        groups = groups.split(',')
    cmd = ['pw', 'useradd']
    if uid:
        cmd.extend(['-u', uid])
    if gid:
        cmd.extend(['-g', gid])
    if groups:
        cmd.extend(['-G', ','.join(groups)])
    if (home is not None):
        cmd.extend(['-d', home])
    if (createhome is True):
        cmd.append('-m')
    if loginclass:
        cmd.extend(['-L', loginclass])
    if shell:
        cmd.extend(['-s', shell])
    if (not salt.utils.is_true(unique)):
        cmd.append('-o')
    gecos_field = _build_gecos({
        'fullname': fullname,
        'roomnumber': roomnumber,
        'workphone': workphone,
        'homephone': homephone,
    })
    cmd.extend(['-c', gecos_field])
    cmd.extend(['-n', name])
    return (__salt__['cmd.retcode'](cmd, python_shell=False) == 0)

dataset/ETHPy150Open saltstack/salt/salt/modules/pw_user.py add/original