|
|
@ -26,6 +26,7 @@ from ansible.module_utils.six import PY3
|
|
|
|
from ansible.module_utils.six.moves import cPickle, StringIO
|
|
|
|
from ansible.module_utils.six.moves import cPickle, StringIO
|
|
|
|
from ansible.module_utils.connection import Connection, ConnectionError, send_data, recv_data
|
|
|
|
from ansible.module_utils.connection import Connection, ConnectionError, send_data, recv_data
|
|
|
|
from ansible.module_utils.service import fork_process
|
|
|
|
from ansible.module_utils.service import fork_process
|
|
|
|
|
|
|
|
from ansible.parsing.ajson import AnsibleJSONEncoder, AnsibleJSONDecoder
|
|
|
|
from ansible.playbook.play_context import PlayContext
|
|
|
|
from ansible.playbook.play_context import PlayContext
|
|
|
|
from ansible.plugins.loader import connection_loader
|
|
|
|
from ansible.plugins.loader import connection_loader
|
|
|
|
from ansible.utils.path import unfrackpath, makedirs_safe
|
|
|
|
from ansible.utils.path import unfrackpath, makedirs_safe
|
|
|
@ -115,7 +116,7 @@ class ConnectionProcess(object):
|
|
|
|
result['exception'] = traceback.format_exc()
|
|
|
|
result['exception'] = traceback.format_exc()
|
|
|
|
finally:
|
|
|
|
finally:
|
|
|
|
result['messages'] = messages
|
|
|
|
result['messages'] = messages
|
|
|
|
self.fd.write(json.dumps(result))
|
|
|
|
self.fd.write(json.dumps(result, cls=AnsibleJSONEncoder))
|
|
|
|
self.fd.close()
|
|
|
|
self.fd.close()
|
|
|
|
|
|
|
|
|
|
|
|
def run(self):
|
|
|
|
def run(self):
|
|
|
@ -275,7 +276,7 @@ def main():
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
os.close(w)
|
|
|
|
os.close(w)
|
|
|
|
rfd = os.fdopen(r, 'r')
|
|
|
|
rfd = os.fdopen(r, 'r')
|
|
|
|
data = json.loads(rfd.read())
|
|
|
|
data = json.loads(rfd.read(), cls=AnsibleJSONDecoder)
|
|
|
|
messages.extend(data.pop('messages'))
|
|
|
|
messages.extend(data.pop('messages'))
|
|
|
|
result.update(data)
|
|
|
|
result.update(data)
|
|
|
|
|
|
|
|
|
|
|
@ -306,10 +307,10 @@ def main():
|
|
|
|
sys.stdout = saved_stdout
|
|
|
|
sys.stdout = saved_stdout
|
|
|
|
if 'exception' in result:
|
|
|
|
if 'exception' in result:
|
|
|
|
rc = 1
|
|
|
|
rc = 1
|
|
|
|
sys.stderr.write(json.dumps(result))
|
|
|
|
sys.stderr.write(json.dumps(result, cls=AnsibleJSONEncoder))
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
rc = 0
|
|
|
|
rc = 0
|
|
|
|
sys.stdout.write(json.dumps(result))
|
|
|
|
sys.stdout.write(json.dumps(result, cls=AnsibleJSONEncoder))
|
|
|
|
|
|
|
|
|
|
|
|
sys.exit(rc)
|
|
|
|
sys.exit(rc)
|
|
|
|
|
|
|
|
|
|
|
|