def members(name, members_list, root=None):
 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(('-R', 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 {0} {1}'.format(name, user), python_shell=False)
     if (not (retcode == 0)):
      break
    else:
     retcode = 0
 else:
  log.error('group.members is not yet supported on this platform')
  return False
 return (not retcode)

def members ( name , members_list , root = None ) : 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 ( ( '-R' , 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 {0} {1}' . format ( name , user ) , python_shell = False ) if ( not ( retcode == 0 ) ) : break 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 .