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.