From ac92ba59319e1d6675b921aa37ef6c8f42c7ae98 Mon Sep 17 00:00:00 2001 From: Frank Brehm Date: Thu, 2 Jan 2025 14:49:33 +0100 Subject: [PATCH] Start evaluating 389ds automember plugin configuration. --- lib/ansible/ds389_plugins_info.py | 69 +++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/lib/ansible/ds389_plugins_info.py b/lib/ansible/ds389_plugins_info.py index c036741..a6d3df5 100644 --- a/lib/ansible/ds389_plugins_info.py +++ b/lib/ansible/ds389_plugins_info.py @@ -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.""" -- 2.39.5