From 222782e347207ce38782ca55216ca9150f21d230 Mon Sep 17 00:00:00 2001 From: Vladimir Botka Date: Mon, 14 Jul 2025 20:54:23 +0200 Subject: [PATCH] Fix #10394 use shlex instead of configparser. --- plugins/modules/sysrc.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/plugins/modules/sysrc.py b/plugins/modules/sysrc.py index cff987449c..328ab1206a 100644 --- a/plugins/modules/sysrc.py +++ b/plugins/modules/sysrc.py @@ -103,7 +103,7 @@ changed: """ from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.six.moves import configparser +from shlex import split import re @@ -131,14 +131,12 @@ class Sysrc(object): Use this dictionary to preform the tests. """ (rc, out, err) = self.run_sysrc('-e', '-a') - parser = configparser.ConfigParser() - parser.read_string('[top]\n' + out) # Add faked top section - conf = {k: parser['top'][k] for k in parser['top']} + conf = dict((part.split('=', 1) for part in split(out, comments=True))) if self.value is None: return self.name in conf else: - return self.name in conf and conf[self.name] == '"%s"' % self.value + return self.name in conf and conf[self.name] == '%s' % self.value def contains(self): (rc, out, err) = self.run_sysrc('-n', self.name)