Export gathering facts to .csv file

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ł

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.

(attachments)

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?

Can you try the block/catch and see if that works?

https://docs.ansible.com/ansible/latest/user_guide/playbooks_blocks.html

ansible_failed_task
The task that returned ‘failed’ and triggered the rescue. For example, to get the name use `[ansible_failed_task.name](http://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.