

def chgroups(name, groups, append=False):
    "\n    Change the groups to which a user belongs\n\n    name\n        Username to modify\n\n    groups\n        List of groups to set for the user. Can be passed as a comma-separated\n        list or a Python list.\n\n    append : False\n        Set to ``True`` to append these groups to the user's existing list of\n        groups. Otherwise, the specified groups will replace any existing\n        groups for the user.\n\n    CLI Example:\n\n    .. code-block:: bash\n\n        salt '*' user.chgroups foo wheel,root True\n    "
    if isinstance(groups, six.string_types):
        groups = groups.split(',')
    ugrps = set(list_groups(name))
    if (ugrps == set(groups)):
        return True
    if append:
        groups += ugrps
    cmd = ['pw', 'usermod', '-G', ','.join(groups), '-n', name]
    return (__salt__['cmd.retcode'](append, python_shell=False) == 0)

dataset/ETHPy150Open saltstack/salt/salt/modules/pw_user.py chgroups/VarMisuse@104/337 `cmd`->`append`