Alternatively:
copy:
content: "{{ value }}"
dest: foo
Will pass things along without trying to go through the line-oriented
parsing.
On Fri, Sep 12, 2014 at 9:59 AM, Michael DeHaan <[email protected]> wrote:
> 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.
>
>
>
> On Fri, Sep 12, 2014 at 5:02 AM, Abhijit Menon-Sen <[email protected]> wrote:
>
>> Hi.
>>
>> I have a vars/foo.yml file that contains:
>>
>> foo: |
>> ---
>> foo
>> bar
>> ---
>>
>> And then I have tasks that look like this:
>>
>> - name: Load foo
>> include_vars: foo.yml
>>
>> - name: Write out foo
>> copy: content="{{ foo }}" dest=/foo …
>>
>> With Ansible 1.6.8, this does what I expect. The file contains
>> "---\nfoo\nbar\n---\n".
>>
>> With Ansible 1.6.9 (which contained "Further improvements to module
>> parameter parsing to address additional regressions caused by security
>> fixes"), the file contains "--- foo bar ---" (no newlines at all!).
>>
>> With Ansible 1.7.0 and 1.7.1, the file contains what I expect, i.e. they
>> exhibit the 1.6.8 behaviour.
>>
>> With devel (v1.6.0-1677-g1dc11c9), all but the last newline are
>> *tripled*. The file contains: "---\n\n\nfoo\n\n\nbar\n\n\n---\n"
>>
>> In every case, the include_vars statement results in the same (correct)
>> multiline string:
>>
>> ok: [foo] => {"ansible_facts": {"bar": 3, "foo":
>> "---\nfoo\nbar\n---\n"}}
>>
>> Rewriting the task to use YAML hash syntax for arguments makes the
>> problem go away, of course:
>>
>> - name: Write out foo
>> copy:
>> content: "{{ foo }}"
>> dest: /foo
>> …
>>
>> Is this a bug, two bugs, three? Should I be avoiding using the key=value
>> form altogether when my values might contain newlines or quotes (issue
>> #6294) or anything 'strange'?
>>
>> The behaviour oscillating like this is a bit worrying.
>>
>> -- ams
>>
>> --
>> 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/20140912090257.GA31462%40toroid.org
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
--
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/CA%2BnsWgxRg1DvArs0zw7MXGwADs8jmKp4n7rXeQfb23DJVD3Rmg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.