Copy action_plugin: encode content when dict.
When content is processed and found to be valid JSON it is decoded into a dict. To write it out to a file we need to encode it back into a string. Addresses GH-5914.pull/4420/head
parent
30611eaac5
commit
1ac19cb981
|
@ -23,6 +23,7 @@ import ansible.utils.template as template
|
||||||
from ansible import errors
|
from ansible import errors
|
||||||
from ansible.runner.return_data import ReturnData
|
from ansible.runner.return_data import ReturnData
|
||||||
import base64
|
import base64
|
||||||
|
import json
|
||||||
import stat
|
import stat
|
||||||
import tempfile
|
import tempfile
|
||||||
import pipes
|
import pipes
|
||||||
|
@ -71,6 +72,11 @@ class ActionModule(object):
|
||||||
# If content is defined make a temp file and write the content into it.
|
# If content is defined make a temp file and write the content into it.
|
||||||
if content is not None:
|
if content is not None:
|
||||||
try:
|
try:
|
||||||
|
# If content comes to us as a dict it should be decoded json.
|
||||||
|
# We need to encode it back into a string to write it out.
|
||||||
|
if type(content) is dict:
|
||||||
|
content_tempfile = self._create_content_tempfile(json.dumps(content))
|
||||||
|
else:
|
||||||
content_tempfile = self._create_content_tempfile(content)
|
content_tempfile = self._create_content_tempfile(content)
|
||||||
source = content_tempfile
|
source = content_tempfile
|
||||||
except Exception, err:
|
except Exception, err:
|
||||||
|
|
Loading…
Reference in New Issue