copying setup module output to file fails

51 views
Skip to first unread message

Pratik Dhandharia

unread,
Sep 29, 2015, 1:48:12 PM9/29/15
to Ansible Project
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.


Brian Coca

unread,
Sep 29, 2015, 2:05:34 PM9/29/15
to Ansible Project
use a template instead, copy's content is not designed to handle complex data




--
Brian Coca

Pratik Dhandharia

unread,
Sep 29, 2015, 2:22:12 PM9/29/15
to Ansible Project
That threw same error.

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

Pratik Dhandharia

unread,
Sep 29, 2015, 4:19:40 PM9/29/15
to Ansible Project

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.

Jean-Yves LENHOF

unread,
Sep 29, 2015, 6:11:22 PM9/29/15
to ansible...@googlegroups.com
ansible -m setup server > file ?
Perhaps, you should explain what you want to do, instead of what you're trying to do technically

Regards,
--
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 ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/2d9d3b89-affc-4824-81c6-57234c7b9f12%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Brian Coca

unread,
Sep 30, 2015, 12:28:13 PM9/30/15
to Ansible Project
ansible -m setup -t /directory all <= this will create a file with
jsonified output for each server queried



--
Brian Coca
Reply all
Reply to author
Forward
0 new messages