diff --git a/ipaserver/install/dogtaginstance.py b/ipaserver/install/dogtaginstance.py index 0b60cf8ba..1e2bfaa07 100644 --- a/ipaserver/install/dogtaginstance.py +++ b/ipaserver/install/dogtaginstance.py @@ -541,6 +541,21 @@ class DogtagInstance(service.Service): else: logger.debug("Added ACI to read groups to %s", dn) + @staticmethod + def ensure_group(group: str, desc: str) -> None: + """Create the group if it does not exist.""" + dn = _group_dn(group) + entry = api.Backend.ldap2.make_entry( + dn, + objectclass=["top", "groupOfUniqueNames"], + cn=[group], + description=[desc], + ) + try: + api.Backend.ldap2.add_entry(entry) + except errors.DuplicateEntry: + pass + @staticmethod def create_user( uid: str,