def auth_add(user, auth):
 ret = {}
 auths = auth.split(',')
 known_auths = auth_list().keys()
 valid_auths = [r for r in auths if (r in known_auths)]
 log.debug('rbac.auth_add - auths={0}, known_auths={1}, valid_auths={2}'.format(auths, known_auths, valid_auths))
 if (len(valid_auths) > 0):
  res = __salt__['cmd.run_all']('usermod -A "{auths}" {login}'.format(login=user, auths=','.join(set((auth_get(user, False) + valid_auths)))))
  if (res['retcode'] > 0):
   ret['Error'] = {'retcode': res['retcode'], 'message': (res['stderr'] if ('stderr' in res) else res['stdout'])}
   return ret
 active_auths = auth_get(user, False)
 for a in auths:
  if (a not in valid_auths):
   ret[a] = 'Unknown'
  elif (a in active_auths):
   ret[a] = 'Added'
  else:
   ret[a] = 'Failed'
 return ret

def auth_add ( user , auth ) : ret = { } auths = auth . split ( ',' ) known_auths = auth_list ( ) . keys ( ) valid_auths = [ r for r in auths if ( r in known_auths ) ] log . debug ( 'rbac.auth_add - auths={0}, known_auths={1}, valid_auths={2}' . format ( auths , known_auths , valid_auths ) ) if ( len ( valid_auths ) > 0 ) : res = __salt__ [ 'cmd.run_all' ] ( 'usermod -A "{auths}" {login}' . format ( login = user , auths = ',' . join ( set ( ( auth_get ( user , False ) + valid_auths ) ) ) ) ) if ( res [ 'retcode' ] > 0 ) : ret [ 'Error' ] = { 'retcode' : res [ 'retcode' ] , 'message' : ( res [ 'stderr' ] if ( 'stderr' in res ) else res [ 'stdout' ] ) } return ret active_auths = auth_get ( user , False ) for a in auths : if ( a not in valid_auths ) : ret [ a ] = 'Unknown' elif ( a in active_auths ) : ret [ a ] = 'Added' else : ret [ a ] = 'Failed' return ret
add authorization to user user : string username auth : string authorization name cli example: .