On Tue, 27 Jan 2015 11:19 -0800, Kathy Allen <[email protected]> wrote:
> TASK: [debug msg={{my_msg}}]
> **************************************************
> Tuesday 27 January 2015 19:05:10 +0000 (0:00:00.000) 0:00:00.040
> *******
> ok: [127.0.0.1] => {
> "msg": "A - i am a runon sentence\ni go on and on and on"
> }
I believe this is being processed by Jinja2, which is ignoring the
newline.
> TASK: [debug msg="B - i am a runon sentence \n i go on and on and on"]
> ********
> Tuesday 27 January 2015 19:05:10 +0000 (0:00:00.005) 0:00:00.045
> *******
> ok: [127.0.0.1] => {
> "msg": "B - i am a runon sentence \\n i go on and on and on"
> }
Here debug is calling exit_json() which in turns calls json.dumps() [1],
which will escape the newline.
>>> json.dumps("one line\nanother line")
'"one line\\nanother line"'
You'll notice that in hipchat you don't see "\\n" but "\n". The function
send_msg() in the hipchat module is correctly calling urllib.urlencode()
to create the URL and then making the external call (no JSON involved
here). I believe this is a separate issue (i.e. hipchat not correctly
interpreting newlines).
[1] - https://docs.python.org/2/library/json.html
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/1422455917.208904.220000997.664FE71E%40webmail.messagingengine.com.
For more options, visit https://groups.google.com/d/optout.