# Track list of failed/success tasks into a file.

**URL:** <https://forum.ansible.com/t/track-list-of-failed-success-tasks-into-a-file/37748>\
**Category:** Ansible Project\
**Created:** [March 10, 2023, 12:06am UTC](https://forum.ansible.com/t/track-list-of-failed-success-tasks-into-a-file/37748 "2023-03-10T00:06:11Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![AharonuReddy](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/aharonureddy/32/5464_2.png) [@AharonuReddy](https://forum.ansible.com/u/AharonuReddy)\
**Post date:** [March 10, 2023, 12:06am UTC](https://forum.ansible.com/t/track-list-of-failed-success-tasks-into-a-file/37748/1 "2023-03-10T00:06:11Z")

</div>

Dear All,

I have static inventory which contains more then 100 hosts/cluster.

While running ansible playbook, there is a chance any of host/cluster got failed to execute the task due to some reason.

We have to capture those this details to one file(CSV) along with other required data. Could anyone please suggest if we have way to track? Thank you

We are using static inventory.

Example we need to track:

Number of hosts/clusters: 110  
Task success: 107  
Failed:3

---

<div class="post-metadata">

**Author:** ![AharonuReddy](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/aharonureddy/32/5464_2.png) [@AharonuReddy](https://forum.ansible.com/u/AharonuReddy)\
**Post date:** [March 10, 2023, 12:11am UTC](https://forum.ansible.com/t/track-list-of-failed-success-tasks-into-a-file/37748/2 "2023-03-10T00:11:06Z")

</div>

Just to add,

Playbook will execute to static inventory host/cluster list over the loop.

---

<div class="post-metadata">

**Author:** ![vbotka](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/vbotka/32/359_2.png) [@vbotka](https://forum.ansible.com/u/vbotka)\
**Post date:** [March 10, 2023, 12:16am UTC](https://forum.ansible.com/t/track-list-of-failed-success-tasks-into-a-file/37748/3 "2023-03-10T00:16:26Z")

</div>

See [https://ansible-runner.readthedocs.io/en/stable/](https://ansible-runner.readthedocs.io/en/stable/)

The artifacts will keep data to create the report.

---

<div class="post-metadata">

**Author:** ![AharonuReddy](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/aharonureddy/32/5464_2.png) [@AharonuReddy](https://forum.ansible.com/u/AharonuReddy)\
**Post date:** [March 10, 2023, 12:31am UTC](https://forum.ansible.com/t/track-list-of-failed-success-tasks-into-a-file/37748/4 "2023-03-10T00:31:07Z")

</div>

Hi Vladimir Botka,

Thanks for your response. I will go through doc ansible-runner.

---

<div class="post-metadata">

**Author:** ![utoddl](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/utoddl/32/249_2.png) [@utoddl](https://forum.ansible.com/u/utoddl)\
**Post date:** [March 10, 2023, 2:44pm UTC](https://forum.ansible.com/t/track-list-of-failed-success-tasks-into-a-file/37748/5 "2023-03-10T14:44:16Z")

</div>

If you mistakenly believe using `ansible-runner` is too much work, then you can instead do even more work to put your tasks in blocks with `rescue` and `always` sections to record the data which you can later collate. See [https://docs.ansible.com/ansible/latest/playbook\_guide/playbooks\_blocks.html#handling-errors-with-blocks](https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_blocks.html#handling-errors-with-blocks) for details.

If you can live with less fine-grained information - i.e. not down to the task level - then familiarize yourself with `RETRY_FILES_ENABLED` and `RETRY_FILES_SAVE_PATH`. See `ansible-config list` for details on those. These tell Ansible to list the hosts which failed a run in the designated file.

Another possibility that fits sort of in-between the first two is to insert a `run_once: true` task at select points in your playbook to compare the `ansible_play_hosts_all` and `ansible_play_hosts` lists to see how they differ. The difference will be the hosts which have failed at that point. The effectiveness of this method depends on the `strategy` your plays employ. In other words, all hosts’ task executions have to be in-sync at the time this `run_once` task runs. (I have not experimented with this. Nor with the other suggestions either.)

---

<div class="post-metadata">

**Author:** ![AharonuReddy](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/aharonureddy/32/5464_2.png) [@AharonuReddy](https://forum.ansible.com/u/AharonuReddy)\
**Post date:** [March 10, 2023, 5:29pm UTC](https://forum.ansible.com/t/track-list-of-failed-success-tasks-into-a-file/37748/6 "2023-03-10T17:29:29Z")

</div>

Thank you Todd.

Many options you have provided. I will go through it and see what works for my requirement.
