# Copy task w/Content being evaluated as parameters and causing it to fail

**URL:** <https://forum.ansible.com/t/copy-task-w-content-being-evaluated-as-parameters-and-causing-it-to-fail/18234>\
**Category:** Ansible Project\
**Created:** [May 14, 2015, 10:53pm UTC](https://forum.ansible.com/t/copy-task-w-content-being-evaluated-as-parameters-and-causing-it-to-fail/18234 "2015-05-14T22:53:35Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mark5](https://avatars.discourse-cdn.com/v4/letter/m/90ced4/32.png) [@Mark5](https://forum.ansible.com/u/Mark5)\
**Post date:** [May 14, 2015, 10:53pm UTC](https://forum.ansible.com/t/copy-task-w-content-being-evaluated-as-parameters-and-causing-it-to-fail/18234/1 "2015-05-14T22:53:35Z")

</div>

I’m trying to capture the contents of a variable that was registered from a previous task, and write it to file for later debugging / troubleshooting if the need arises.

The variable essentially has this in it:

{“changed”: true, “cmd”: [“mongo”, “–eval”, “printjson(rs.add("myserver"))”], “delta”: “0:00:00.130748”, “end”: “2015-05-14 22:43:14.453176”, “rc”: 0, “start”: “2015-05-14 22:43:14.322428”, “stderr”: “”, “stdout”: “MongoDB shell version: 3.0.3\nconnecting to: test\n{\n\t"ok" : 0,\n\t"errmsg" : "Found two member configurations with same host field, members.1.host == members.3.host == myserver",\n\t"code" : 103\n}”, “warnings”: }

I then want to record it, possibly to another server…

- copy: content=“‘{{ theVariable }}’” dest=/somefile-{{ ansible\_fqdn }}.json

delegate\_to: masterServer

Ansible fails with the following error:

fatal: a duplicate parameter was found in the argument string ()

I’ve observed this (or something similar) a couple of times when using the “content” parameter with copy.

Is there a way to get copy w/ content + variables to work…? Aside from using shell and | tee the results… but there’s been a few cases where this functionality would have been helpful.

Thanks.

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [May 15, 2015, 1:39pm UTC](https://forum.ansible.com/t/copy-task-w-content-being-evaluated-as-parameters-and-causing-it-to-fail/18234/2 "2015-05-15T13:39:06Z")

</div>

I would switch to the template module, copy's content is not a good  
method for anything but trivial file content.

---

<div class="post-metadata">

**Author:** ![Mark5](https://avatars.discourse-cdn.com/v4/letter/m/90ced4/32.png) [@Mark5](https://forum.ansible.com/u/Mark5)\
**Post date:** [May 18, 2015, 7:27pm UTC](https://forum.ansible.com/t/copy-task-w-content-being-evaluated-as-parameters-and-causing-it-to-fail/18234/3 "2015-05-18T19:27:24Z")

</div>

Brain - trying to capture output of an ansible command. Can’t use a template in that situation unless there’s some way it can pull in runtime variables…?

---

<div class="post-metadata">

**Author:** ![Mark5](https://avatars.discourse-cdn.com/v4/letter/m/90ced4/32.png) [@Mark5](https://forum.ansible.com/u/Mark5)\
**Post date:** [May 18, 2015, 7:29pm UTC](https://forum.ansible.com/t/copy-task-w-content-being-evaluated-as-parameters-and-causing-it-to-fail/18234/4 "2015-05-18T19:29:19Z")

</div>

Ideally, something like

- copy var\_content=myVariable dest=/tmp/myFile.json

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [May 18, 2015, 8:02pm UTC](https://forum.ansible.com/t/copy-task-w-content-being-evaluated-as-parameters-and-causing-it-to-fail/18234/5 "2015-05-18T20:02:56Z")

</div>

templates should get all current variables by default
