Export gathering facts to .csv file

3,582 views
Skip to first unread message

michal...@snpgroup.com

unread,
Mar 6, 2019, 10:41:49 AM3/6/19
to Ansible Project
Hello,

I'm new user in Ansible technology and I have a problem with export gathering facts about host to .csv file.

I would like to generate report in .csv file from ansible-playbook results. Ansible playbook reads facts about hosts and results of tasks and next save them to .csv file. It works. But, problem is with hosts which ansible can't connect, because finally in my report I have only facts and tasks results from hosts which ansible can connect, but about other hosts I don't have any information. My idea is that this playbook will be run once a day in cron and generate report for me. Next I will be read this report and I will be know with witch host ansible have problems for example with connection, run task and many other. It's very important in works with hundreds hosts.

So my question is: What Can I export gathering facts from playbook (with fatal message too) to external file?

Now my playbook is:


What I can modify my playbook for export gathering facts information to .csv about all hosts (fatal too)? Do you have any idea?

Regrads,
Michał

Kuldip Madnani

unread,
Mar 6, 2019, 10:31:01 PM3/6/19
to ansible...@googlegroups.com
Ansible can gather facts from hosts only when it is able to connect to them, as multiple commands are executed on that host to gather that information.

--
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/ec0a30bc-d146-4ec0-8c2f-1af7a3f2eb97%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Michał Misiak

unread,
Mar 8, 2019, 6:20:01 AM3/8/19
to Ansible Project
Yes, I know. And I catch gather facts from connected machine and save them in .csv file. This file is my informaction about hosts which ansbile can connection only, but I would like to have information about all of host. What can I catch a fatal messege about connection refused to some host and transfer them to file?

Ankit Vashistha

unread,
Mar 12, 2019, 6:32:55 AM3/12/19
to ansible...@googlegroups.com
Can you try the block/catch and see if that works?


ansible_failed_task
The task that returned ‘failed’ and triggered the rescue. For example, to get the name use ansible_failed_task.name.
ansible_failed_result
The captured return result of the failed task that triggered the rescue. This would equate to having used this var in the register keyword.

Regards,
Ankit


On Fri, Mar 8, 2019 at 4:50 PM Michał Misiak <michal...@snpgroup.com> wrote:
Yes, I know. And I catch gather facts from connected machine and save them in .csv file. This file is my informaction about hosts which ansbile can connection only, but I would like to have information about all of host. What can I catch a fatal messege about connection refused to some host and transfer them to file?

--
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.
Reply all
Reply to author
Forward
0 new messages