yaml callback fails on python3
When the URI module returns complex JSON objects, the YAML callback fails while trying to represent these objects. The problem arises because the filter method returns an iterator in Python 3, rather than a str object. Therefore, the str method expandtabs() is not available, and the callback fails with the following error: [WARNING]: Failure using method (v2_runner_on_failed) in callback plugin (<ansible.plugins.callback.yaml.CallbackModule object at 0x7f7c7ed8aa20>): 'filter' object has no attribute 'expandtabs' Issue can be replicated by running this playbook: - hosts: localhost gather_facts: false tasks: - uri: url: https://jsonplaceholder.typicode.com/posts ansible-playbook tmp.yml -v
This commit is contained in:
parent
423b0e0f58
commit
5839f07e0f
1 changed files with 1 additions and 1 deletions
|
@ -47,7 +47,7 @@ def my_represent_scalar(self, tag, value, style=None):
|
|||
# ...no trailing space
|
||||
value = value.rstrip()
|
||||
# ...and non-printable characters
|
||||
value = filter(lambda x: x in string.printable, value)
|
||||
value = ''.join(x for x in value if x in string.printable)
|
||||
# ...tabs prevent blocks from expanding
|
||||
value = value.expandtabs()
|
||||
# ...and odd bits of whitespace
|
||||
|
|
Loading…
Reference in a new issue