def members(name, members_list, root=None):
    '''
    Replaces members of the group with a provided list.

    name
        Name of the group to modify

    members_list
        Username list to set into the group

    root
        Directory to chroot into

    CLI Example:

        salt '*' group.members foo 'user1,user2,user3,...'

    Replaces a membership list for a local group 'foo'.
        foo:x:1234:user1,user2,user3,...
    '''
    on_redhat_5 = __grains__.get('os_family') == 'RedHat' and __grains__.get('osmajorrelease') == '5'
    on_suse_11 = __grains__.get('os_family') == 'Suse' and __grains__.get('osmajorrelease') == '11'

    if __grains__['kernel'] == 'Linux':
        if on_redhat_5:
            cmd = ['gpasswd', '-M', members_list, name]
        elif on_suse_11:
            for old_member in __salt__['group.info'](name).get('members'):
                __salt__['cmd.run']('groupmod -R {0} {1}'.format(old_member, name), python_shell=False)
            cmd = ['groupmod', '-A', members_list, name]
        else:
            cmd = ['gpasswd', '--members', members_list, name]
        if root is not None:
            cmd.extend(('--root', root))
        retcode = __salt__['cmd.retcode'](cmd, python_shell=False)
    elif __grains__['kernel'] == 'OpenBSD':
        retcode = 1
        grp_info = __salt__['group.info'](name)
        if grp_info and name in grp_info['name']:
            __salt__['cmd.run']('groupdel {0}'.format(name),
                                python_shell=False)
            __salt__['cmd.run']('groupadd -g {0} {1}'.format(
                grp_info['gid'], name), python_shell=False)
            for user in members_list.split(","):
                if user:
                    retcode = __salt__['cmd.retcode'](
                        ['usermod', '-G', name, user],
                        python_shell=False)
                    if not retcode == 0:
                        break
                # provided list is '': users previously deleted from group
                else:
                    retcode = 0
    else:
        log.error('group.members is not yet supported on this platform')
        return False

    return not retcode
Replaces members of the group with a provided list.

    name
        Name of the group to modify

    members_list
        Username list to set into the group

    root
        Directory to chroot into

    CLI Example:

        salt '*' group.members foo 'user1,user2,user3,...'

    Replaces a membership list for a local group 'foo'.
        foo:x:1234:user1,user2,user3,...