#NEWLINE# def group_present( name , policies = None , policies_from_pillars = None , managed_policies = None , users = None , path = '/' , region = None , key = None , keyid = None , profile = None ) : #NEWLINE# #INDENT# "\n\n    .. versionadded:: 2015.8.0\n\n    Ensure the IAM group is present\n\n    name (string)\n        The name of the new group.\n\n    path (string)\n        The path for the group, defaults to '/'\n\n    policies (dict)\n        A dict of IAM group policy documents.\n\n    policies_from_pillars (list)\n        A list of pillars that contain role policy dicts. Policies in the\n        pillars will be merged in the order defined in the list and key\n        conflicts will be handled by later defined keys overriding earlier\n        defined keys. The policies defined here will be merged with the\n        policies defined in the policies argument. If keys conflict, the keys\n        in the policies argument will override the keys defined in\n        policies_from_pillars.\n\n    manaaged_policies (list)\n        A list of policy names or ARNs that should be attached to this group.\n\n    users (list)\n        A list of users to be added to the group.\n\n    region (string)\n        Region to connect to.\n\n    key (string)\n        Secret key to be used.\n\n    keyid (string)\n        Access key to be used.\n\n    profile (dict)\n        A dict with region, key and keyid, or a pillar key (string) that\n        contains a dict with region, key and keyid.\n    " #NEWLINE# ret = { #NEWLINE# #INDENT# 'name' : created , #NEWLINE# 'result' : True , #NEWLINE# 'comment' : '' , #NEWLINE# 'changes' : { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } #NEWLINE# if ( not policies ) : #NEWLINE# #INDENT# policies = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# if ( not policies_from_pillars ) : #NEWLINE# #INDENT# policies_from_pillars = [ ] #NEWLINE# #UNINDENT# if ( not managed_policies ) : #NEWLINE# #INDENT# managed_policies = [ ] #NEWLINE# #UNINDENT# _policies = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# for policy in policies_from_pillars : #NEWLINE# #INDENT# _policy = __salt__ [ 'pillar.get' ] ( policy ) #NEWLINE# _policies . update ( _policy ) #NEWLINE# #UNINDENT# _policies . update ( policies ) #NEWLINE# exists = __salt__ [ 'boto_iam.get_group' ] ( group_name = name , region = region , key = key , keyid = keyid , profile = profile ) #NEWLINE# if ( not exists ) : #NEWLINE# #INDENT# if __opts__ [ 'test' ] : #NEWLINE# #INDENT# ret [ 'comment' ] = 'IAM group {0} is set to be created.' . format ( name ) #NEWLINE# ret [ 'result' ] = None #NEWLINE# return ret #NEWLINE# #UNINDENT# created = __salt__ [ 'boto_iam.create_group' ] ( group_name = name , path = path , region = region , key = key , keyid = keyid , profile = profile ) #NEWLINE# if ( not created ) : #NEWLINE# #INDENT# ret [ 'comment' ] = 'Failed to create IAM group {0}.' . format ( name ) #NEWLINE# ret [ 'result' ] = False #NEWLINE# return ret #NEWLINE# #UNINDENT# ret [ 'changes' ] [ 'group' ] = created #NEWLINE# ret [ 'comment' ] = os . linesep . join ( [ ret [ 'comment' ] , 'Group {0} has been created.' . format ( name ) ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# ret [ 'comment' ] = os . linesep . join ( [ ret [ 'comment' ] , 'Group {0} is present.' . format ( name ) ] ) #NEWLINE# #UNINDENT# _ret = _group_policies_present ( name , _policies , region , key , keyid , profile ) #NEWLINE# ret [ 'changes' ] = dictupdate . update ( ret [ 'changes' ] , _ret [ 'changes' ] ) #NEWLINE# ret [ 'comment' ] = ' ' . join ( [ ret [ 'comment' ] , _ret [ 'comment' ] ] ) #NEWLINE# if ( not _ret [ 'result' ] ) : #NEWLINE# #INDENT# ret [ 'result' ] = _ret [ 'result' ] #NEWLINE# return ret #NEWLINE# #UNINDENT# _ret = _group_policies_attached ( name , managed_policies , region , key , keyid , profile ) #NEWLINE# ret [ 'changes' ] = dictupdate . update ( ret [ 'changes' ] , _ret [ 'changes' ] ) #NEWLINE# ret [ 'comment' ] = ' ' . join ( [ ret [ 'comment' ] , _ret [ 'comment' ] ] ) #NEWLINE# if ( not _ret [ 'result' ] ) : #NEWLINE# #INDENT# ret [ 'result' ] = _ret [ 'result' ] #NEWLINE# return ret #NEWLINE# #UNINDENT# if ( users is not None ) : #NEWLINE# #INDENT# log . debug ( 'Users are : {0}.' . format ( users ) ) #NEWLINE# existing_users = __salt__ [ 'boto_iam.get_group_members' ] ( group_name = name , region = region , key = key , keyid = keyid , profile = profile ) #NEWLINE# ret = _case_group ( ret , users , name , existing_users , region , key , keyid , profile ) #NEWLINE# #UNINDENT# return ret