mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-08-03 12:44:22 -07:00
Fix #10394 use shlex instead of configparser.
This commit is contained in:
parent
c9f33a7dec
commit
222782e347
1 changed files with 3 additions and 5 deletions
|
@ -103,7 +103,7 @@ changed:
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
from ansible.module_utils.six.moves import configparser
|
from shlex import split
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
|
||||||
|
@ -131,14 +131,12 @@ class Sysrc(object):
|
||||||
Use this dictionary to preform the tests.
|
Use this dictionary to preform the tests.
|
||||||
"""
|
"""
|
||||||
(rc, out, err) = self.run_sysrc('-e', '-a')
|
(rc, out, err) = self.run_sysrc('-e', '-a')
|
||||||
parser = configparser.ConfigParser()
|
conf = dict((part.split('=', 1) for part in split(out, comments=True)))
|
||||||
parser.read_string('[top]\n' + out) # Add faked top section
|
|
||||||
conf = {k: parser['top'][k] for k in parser['top']}
|
|
||||||
|
|
||||||
if self.value is None:
|
if self.value is None:
|
||||||
return self.name in conf
|
return self.name in conf
|
||||||
else:
|
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):
|
def contains(self):
|
||||||
(rc, out, err) = self.run_sysrc('-n', self.name)
|
(rc, out, err) = self.run_sysrc('-n', self.name)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue