Fix the lines lookup to work on python3 (#17291)
Since stdout is (on python3) of type 'bytes', callbacks plugins fail in the test suite, because calls backs expect a string.
This commit is contained in:
parent
4ba90a3817
commit
9245c786db
1 changed files with 2 additions and 1 deletions
|
@ -21,6 +21,7 @@ __metaclass__ = type
|
|||
import subprocess
|
||||
from ansible.errors import AnsibleError
|
||||
from ansible.plugins.lookup import LookupBase
|
||||
from ansible.module_utils._text import to_text
|
||||
|
||||
class LookupModule(LookupBase):
|
||||
|
||||
|
@ -31,7 +32,7 @@ class LookupModule(LookupBase):
|
|||
p = subprocess.Popen(term, cwd=self._loader.get_basedir(), shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
|
||||
(stdout, stderr) = p.communicate()
|
||||
if p.returncode == 0:
|
||||
ret.extend(stdout.splitlines())
|
||||
ret.extend([to_text(l) for l in stdout.splitlines()])
|
||||
else:
|
||||
raise AnsibleError("lookup_plugin.lines(%s) returned %d" % (term, p.returncode))
|
||||
return ret
|
||||
|
|
Loading…
Reference in a new issue