# multiple multi-line parsing regressions

**URL:** <https://forum.ansible.com/t/multiple-multi-line-parsing-regressions/16189>\
**Category:** Ansible Project\
**Created:** [September 12, 2014, 9:02am UTC](https://forum.ansible.com/t/multiple-multi-line-parsing-regressions/16189 "2014-09-12T09:02:57Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Abhijit\_Menon-Sen2](https://avatars.discourse-cdn.com/v4/letter/a/ea5d25/32.png) [@Abhijit\_Menon-Sen2](https://forum.ansible.com/u/Abhijit_Menon-Sen2)\
**Post date:** [September 12, 2014, 9:02am UTC](https://forum.ansible.com/t/multiple-multi-line-parsing-regressions/16189/1 "2014-09-12T09:02:57Z")

</div>

Hi.

I have a vars/foo.yml file that contains:

&nbsp;&nbsp;&nbsp;&nbsp;foo: |

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [September 12, 2014, 1:59pm UTC](https://forum.ansible.com/t/multiple-multi-line-parsing-regressions/16189/2 "2014-09-12T13:59:39Z")

</div>

How about not using the silly content parameter?

It’s really intended for exceedingly basic one-liner things, and as you know in Ansible that value will get templated out to form a command line to the module, so having weird newlines in there, without the variable, wouldn’t make much sense anyway.

Using the “template” module can also be a great solution if you want to trivially just push some value in to the remote side.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [September 12, 2014, 2:29pm UTC](https://forum.ansible.com/t/multiple-multi-line-parsing-regressions/16189/3 "2014-09-12T14:29:23Z")

</div>

Alternatively:

copy:  
content: “{{ value }}”  
dest: foo

Will pass things along without trying to go through the line-oriented parsing.

---

<div class="post-metadata">

**Author:** ![Abhijit\_Menon-Sen2](https://avatars.discourse-cdn.com/v4/letter/a/ea5d25/32.png) [@Abhijit\_Menon-Sen2](https://forum.ansible.com/u/Abhijit_Menon-Sen2)\
**Post date:** [September 12, 2014, 3:34pm UTC](https://forum.ansible.com/t/multiple-multi-line-parsing-regressions/16189/4 "2014-09-12T15:34:07Z")

</div>

Yes, as I mentioned in my mail, that's the workaround I'm already using.  
I do think the documentation should mention something about when to not  
use key=value syntax, though.

I find copy's "content" parameter quite convenient to put things like  
policy-rc.d scripts and SSL keys from ansible-vault in place. But even  
if we disregard that as silly, authorized\_key's "key" parameter has  
exactly the same problem with parsing.

The documentation for it uses key="{{ lookup … }}" \_everywhere\_, and  
that breaks when your key file starts with «from="12.34.45.56", …»  
(which is what github issue #6294 was about).

Would you take a patch to change all the example to use key: "…"  
syntax instead?

-- ams

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [September 12, 2014, 7:14pm UTC](https://forum.ansible.com/t/multiple-multi-line-parsing-regressions/16189/5 "2014-09-12T19:14:42Z")

</div>

Changing all the examples would make very good since for the short term, though I believe we can also deal with fixing the \n issue.

I’m not aware of anything wrong with the key parameter, usually that’s one entry per line anyway, and also only used with a single line, but multiple lines don’t hurt that file IIRC.

---

<div class="post-metadata">

**Author:** ![Abhijit\_Menon-Sen2](https://avatars.discourse-cdn.com/v4/letter/a/ea5d25/32.png) [@Abhijit\_Menon-Sen2](https://forum.ansible.com/u/Abhijit_Menon-Sen2)\
**Post date:** [September 19, 2014, 4:39am UTC](https://forum.ansible.com/t/multiple-multi-line-parsing-regressions/16189/6 "2014-09-19T04:39:47Z")

</div>

> Changing all the examples would make very good since for the short  
> term, though I believe we can also deal with fixing the \n issue.

OK, I'll submit a pull request to change the examples.

> I'm not aware of anything wrong with the key parameter, usually that's  
> one entry per line anyway, and also only used with a single line, but  
> multiple lines don't hurt that file IIRC.

No, the problem with authorized\_key's key= is not multiple lines, but  
quoting. For example, if you want to install the following key:

&nbsp;&nbsp;&nbsp;from="1.2.3.4",command="rsync --server -logDtpre.iLsf --delete . foo/",no-pty,no-port-forwarding,no-X11-forwarding,no-agent-forwarding ssh-rsa …

using something like:

&nbsp;&nbsp;&nbsp;&nbsp;authorized\_key: user=foo key="{{ lookup('file', …) }}"

Then you get:

fatal: [localhost] =\> A variable inserted a new parameter into the  
module args. Be sure to quote variables if they contain equal signs (for  
example: "{{var}}").

This has come up a few times, including in the bug report that I linked  
to in my earlier post. For this problem, too, using the "key: value"  
syntax makes the problem go away. So I'll change those examples too.

Independent of that, if you want to outline your approach to solving the  
\n and quoting problems, I'd be happy to work on them.

-- ams

---

<div class="post-metadata">

**Author:** ![Abhijit\_Menon-Sen2](https://avatars.discourse-cdn.com/v4/letter/a/ea5d25/32.png) [@Abhijit\_Menon-Sen2](https://forum.ansible.com/u/Abhijit_Menon-Sen2)\
**Post date:** [September 19, 2014, 5:05am UTC](https://forum.ansible.com/t/multiple-multi-line-parsing-regressions/16189/7 "2014-09-19T05:05:36Z")

</div>

Done: [https://github.com/ansible/ansible/pull/9068](https://github.com/ansible/ansible/pull/9068)

Thanks for your comments.

-- ams
