def profile_get(user, default_hidden=True):
 user_profiles = []
 with salt.utils.fopen('/etc/user_attr', 'r') as user_attr:
  for profile in user_attr:
   profile = profile.strip().split(':')
   if (len(profile) != 5):
    continue
   if (profile[0] != user):
    continue
   attrs = {}
   for attr in profile[4].strip().split(';'):
    (attr_key, attr_val) = attr.strip().split('=')
    if (attr_key in ['auths', 'profiles', 'roles']):
     attrs[attr_key] = attr_val.strip().split(',')
    else:
     attrs[attr_key] = attr_val
   if ('profiles' in attrs):
    user_profiles.extend(attrs['profiles'])
 if default_hidden:
  for profile in profile_list(default_only=True):
   if (profile in user_profiles):
    user_profiles.remove(profile)
 return list(set(user_profiles))

def profile_get ( user , default_hidden = True ) : user_profiles = [ ] with salt . utils . fopen ( '/etc/user_attr' , 'r' ) as user_attr : for profile in user_attr : profile = profile . strip ( ) . split ( ':' ) if ( len ( profile ) != 5 ) : continue if ( profile [ 0 ] != user ) : continue attrs = { } for attr in profile [ 4 ] . strip ( ) . split ( ';' ) : ( attr_key , attr_val ) = attr . strip ( ) . split ( '=' ) if ( attr_key in [ 'auths' , 'profiles' , 'roles' ] ) : attrs [ attr_key ] = attr_val . strip ( ) . split ( ',' ) else : attrs [ attr_key ] = attr_val if ( 'profiles' in attrs ) : user_profiles . extend ( attrs [ 'profiles' ] ) if default_hidden : for profile in profile_list ( default_only = True ) : if ( profile in user_profiles ) : user_profiles . remove ( profile ) return list ( set ( user_profiles ) )
list profiles for user user : string username default_hidden : boolean hide default profiles cli example: .