copying setup module output to file fails

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.

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

That threw same error.

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

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.

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

Regards,

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