(username, groupname)
Ensure given user is member of given group

    Group and User must already exist.
Ensure given user is member of given group
Ensure given user is member of given group
def ensure_user_group(username, groupname):
    """
    Ensure given user is member of given group

    Group and User must already exist.
    """
    group = grp.getgrnam(groupname)
    if username in group.gr_mem:
        return

    subprocess.check_call(["gpasswd", "--add", username, groupname])
def ensure_user_group ( username , groupname ) : group = grp . getgrnam ( groupname ) if username in group . gr_mem : return subprocess . check_call ( [ "gpasswd" , "--add" , username , groupname ] )