mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-08-02 04:04:23 -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.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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue