use ansible json encoder for results in callbacks (#46830)

* use ansible json encoder for results in callbacks
This commit is contained in:
Brian Coca 2018-10-12 09:37:56 -04:00 committed by GitHub
parent ade5d938c3
commit 643ff29d2d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 18 additions and 13 deletions

View file

@ -70,8 +70,9 @@ import getpass
from datetime import datetime
from os.path import basename
from ansible.plugins.callback import CallbackBase
from ansible.module_utils.urls import open_url
from ansible.parsing.ajson import AnsibleJSONEncoder
from ansible.plugins.callback import CallbackBase
class SplunkHTTPCollectorSource(object):
@ -116,7 +117,7 @@ class SplunkHTTPCollectorSource(object):
data['ansible_result'] = result._result
# This wraps the json payload in and outer json event needed by Splunk
jsondata = json.dumps(data, sort_keys=True)
jsondata = json.dumps(data, cls=AnsibleJSONEncoder, sort_keys=True)
jsondata = '{"event":' + jsondata + "}"
open_url(