# copying setup module output to file fails

**URL:** <https://forum.ansible.com/t/copying-setup-module-output-to-file-fails/19379>\
**Category:** Ansible Project\
**Created:** [September 29, 2015, 5:47pm UTC](https://forum.ansible.com/t/copying-setup-module-output-to-file-fails/19379 "2015-09-29T17:47:30Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pratik\_Dhandharia](https://avatars.discourse-cdn.com/v4/letter/p/8baadc/32.png) [@Pratik\_Dhandharia](https://forum.ansible.com/u/Pratik_Dhandharia)\
**Post date:** [September 29, 2015, 5:47pm UTC](https://forum.ansible.com/t/copying-setup-module-output-to-file-fails/19379/1 "2015-09-29T17:47:30Z")

</div>

Hi All,

I have a simple ansible script that is trying to gather info using the setup module and copying that information onto a temp file. Here is what my script looks like:

- hosts: all  
tasks:
- name: gather info  
setup:  
register: info
- name: copy info  
copy: content=“{{ info }}” dest=/tmp/info\_test.log

When I run this script, I get the following error:

fatal: [localhost] =\> error parsing argument string ‘content="{ …  
… // Json formatted information registered in the info variable  
…}} " dest=/tmp/info\_test.log’, try quoting the entire line.

Is there any other way of capturing the info produced by setup module, and store it in a file?

Also does this seems to be a bug in the copy module? I feel this is failing because the json output is not formatted correctly.

Any help is appreciated.

---

<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:** [September 29, 2015, 6:05pm UTC](https://forum.ansible.com/t/copying-setup-module-output-to-file-fails/19379/2 "2015-09-29T18:05:15Z")

</div>

use a template instead, copy's content is not designed to handle complex data

---

<div class="post-metadata">

**Author:** ![Pratik\_Dhandharia](https://avatars.discourse-cdn.com/v4/letter/p/8baadc/32.png) [@Pratik\_Dhandharia](https://forum.ansible.com/u/Pratik_Dhandharia)\
**Post date:** [September 29, 2015, 6:22pm UTC](https://forum.ansible.com/t/copying-setup-module-output-to-file-fails/19379/3 "2015-09-29T18:22:12Z")

</div>

That threw same error.

I was wondering if there is a direct way of copying/saving output of setup module to a file.

---

<div class="post-metadata">

**Author:** ![Pratik\_Dhandharia](https://avatars.discourse-cdn.com/v4/letter/p/8baadc/32.png) [@Pratik\_Dhandharia](https://forum.ansible.com/u/Pratik_Dhandharia)\
**Post date:** [September 29, 2015, 8:19pm UTC](https://forum.ansible.com/t/copying-setup-module-output-to-file-fails/19379/4 "2015-09-29T20:19:39Z")

</div>

So I figured out the issue.

This was an environment issue as an environment variable http\_proxy was set starting with value ‘{#’

Hence ansible was not able to parse the json formatted string.

---

<div class="post-metadata">

**Author:** ![jean-yves](https://avatars.discourse-cdn.com/v4/letter/j/a587f6/32.png) [@jean-yves](https://forum.ansible.com/u/jean-yves)\
**Post date:** [September 29, 2015, 10:11pm UTC](https://forum.ansible.com/t/copying-setup-module-output-to-file-fails/19379/5 "2015-09-29T22:11:02Z")

</div>

ansible -m setup server \> file ?  
Perhaps, you should explain what you want to do, instead of what you’re trying to do technically

Regards,

---

<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:** [September 30, 2015, 4:28pm UTC](https://forum.ansible.com/t/copying-setup-module-output-to-file-fails/19379/6 "2015-09-30T16:28:03Z")

</div>

ansible -m setup -t /directory all \<= this will create a file with  
jsonified output for each server queried
