]> Frank Brehm's Git Trees - pixelpark/pp-admin-tools.git/commitdiff
Start evaluating 389ds automember plugin configuration.
authorFrank Brehm <frank.brehm@pixelpark.com>
Thu, 2 Jan 2025 13:49:33 +0000 (14:49 +0100)
committerFrank Brehm <frank.brehm@pixelpark.com>
Thu, 2 Jan 2025 13:49:33 +0000 (14:49 +0100)
lib/ansible/ds389_plugins_info.py

index c0367419d7d47984b6ab25a085ea23ed2e72b9ee..a6d3df5615a6bd7117fb5c27b3fa4c3294d7abdc 100644 (file)
@@ -94,6 +94,7 @@ class Ds389PluginsInfo(object):
         if not self.cmd:
             return {}
 
+        self.get_automember()
         self.get_memberof()
         self.get_referint()
         self.get_root_dn_access()
@@ -119,6 +120,74 @@ class Ds389PluginsInfo(object):
 
         return value
 
+    # --------------------------------------------------------------------------
+    def get_automember(self):
+        """Get configuration, definitions and regular expressions of the automember plugnin."""
+        proc = run(
+            [self.cmd, self.instance, 'plugin', 'show'],
+            capture_output=True, encoding=self.encoding)
+        if proc.stderr:
+            module.warn(proc.stderr)
+        if proc.returncode:
+            return
+
+        key = 'automember'
+        re_processmodifyops = re.compile(r'^automemberProcessModifyOps:\s+(.*)', re.IGNORECASE)
+
+        if key not in self.result:
+            self.result[key] = {}
+
+        if 'definition' not in self.result[key]:
+            self.result[key]['definition'] = {}
+
+        for line in proc.stdout.splitlines():
+            line = line.strip()
+            if not line:
+                continue
+
+            m = self.re_cn.match(line)
+            if m:
+                self.result[key]['cn'] = m.group(1)
+                continue
+
+            m = self.re_plugin_version.match(line)
+            if m:
+                self.result[key]['plugin_version'] = m.group(1)
+                continue
+
+            m = self.re_enabled.match(line)
+            if m:
+                self.result[key]['enabled'] = self.mangle_value(m.group(1))
+                continue
+
+            m = re_processmodifyops.match(line)
+            if m:
+                self.result[key]['process_modify_ops'] = self.mangle_value(m.group(1))
+                continue
+
+        self._get_automember_definitions()
+
+    # --------------------------------------------------------------------------
+    def _get_automember_definitions(self):
+
+        proc = run(
+            [self.cmd, self.instance, 'plugin', 'list', 'definitions'],
+            capture_output=True, encoding=self.encoding)
+        if proc.stderr:
+            module.warn(proc.stderr)
+        if proc.returncode:
+            return
+
+        key = 'automember'
+
+        for def_name in proc.stdout.splitlines():
+            def_name = def_name.strip()
+            if not def_name:
+                continue
+
+            if def_name not in self.result[key]['definition']:
+                self.result[key]['definition'][def_name] = {}
+
     # --------------------------------------------------------------------------
     def get_memberof(self):
         """Get config of memberof plugin."""