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)