vaultmanager/modules/VaultManagerLDAP.py
def create_groups_policies(self):
        """
        Create a policy for each group
        """
        self.logger.info("Creating groups policies")
        ldap_groups = list(sorted(set(
            [group for user in self.ldap_users for group in
             self.ldap_users[user]])))
        for read_group in self.conf["groups"]["groups_to_add"]:
            if read_group not in ldap_groups:
                self.logger.warning("Group " + read_group +
                                    " in conf file 't been found in LDAP "
                                    "groups. Default conf file. "
                                    "The default group policy will be created "
                                    "anyway.")
        with open(
                os.path.join(
                    self.policies_folder,
                    self.conf["general"]["group"]["default_policy"]
                ), 'r') as fd:
            default_policy = fd.read()
        for group in self.conf["groups"]["groups_to_add"]:
            policy_file = os.path.join(self.group_policies_folder,
                                       group + ".hcl")
            self.group_policies_to_create.append(policy_file)
            if os.path.isfile(policy_file):
                self.logger.info(
                    "Policy for group " + group +
                    " already exists and will not be overwritten"
                )
            else:
                with open(policy_file, 'w+') as fd:
                    fd.write(default_policy.replace("{{GROUP_NAME}}", group))
                    self.logger.info("Default policy for " + group + " written")

        Create a policy for each group
        
Create a policy for each group
Create a policy for each group
def create_groups_policies(self):
        self.logger.info("Creating groups policies")
        ldap_groups = list(sorted(set(
            [group for user in self.ldap_users for group in
             self.ldap_users[user]])))
        for read_group in self.conf["groups"]["groups_to_add"]:
            if read_group not in ldap_groups:
                self.logger.warning("Group " + read_group +
                                    " in conf file 't been found in LDAP "
                                    "groups. Default conf file. "
                                    "The default group policy will be created "
                                    "anyway.")
        with open(
                os.path.join(
                    self.policies_folder,
                    self.conf["general"]["group"]["default_policy"]
                ), 'r') as fd:
            default_policy = fd.read()
        for group in self.conf["groups"]["groups_to_add"]:
            policy_file = os.path.join(self.group_policies_folder,
                                       group + ".hcl")
            self.group_policies_to_create.append(policy_file)
            if os.path.isfile(policy_file):
                self.logger.info(
                    "Policy for group " + group +
                    " already exists and will not be overwritten"
                )
            else:
                with open(policy_file, 'w+') as fd:
                    fd.write(default_policy.replace("{{GROUP_NAME}}", group))
                    self.logger.info("Default policy for " + group + " written")
def create_groups_policies ( self ) : self . logger . info ( "Creating groups policies" ) ldap_groups = list ( sorted ( set ( [ group for user in self . ldap_users for group in self . ldap_users [ user ] ] ) ) ) for read_group in self . conf [ "groups" ] [ "groups_to_add" ] : if read_group not in ldap_groups : self . logger . warning ( "Group " + read_group + " in conf file 't been found in LDAP " "groups. Default conf file. " "The default group policy will be created " "anyway." ) with open ( os . path . join ( self . policies_folder , self . conf [ "general" ] [ "group" ] [ "default_policy" ] ) , 'r' ) as fd : default_policy = fd . read ( ) for group in self . conf [ "groups" ] [ "groups_to_add" ] : policy_file = os . path . join ( self . group_policies_folder , group + ".hcl" ) self . group_policies_to_create . append ( policy_file ) if os . path . isfile ( policy_file ) : self . logger . info ( "Policy for group " + group + " already exists and will not be overwritten" ) else : with open ( policy_file , 'w+' ) as fd : fd . write ( default_policy . replace ( "{{GROUP_NAME}}" , group ) ) self . logger . info ( "Default policy for " + group + " written" )
Create a policy for each group
Create a policy for each group
"""
        Create a policy for each group
        """
self