Fix #10394 use shlex instead of configparser.

This commit is contained in:
Vladimir Botka 2025-07-14 20:54:23 +02:00 committed by Felix Fontein
commit 222782e347

View file

@ -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)