# Help - generating a table of task results in ansible

**URL:** <https://forum.ansible.com/t/help-generating-a-table-of-task-results-in-ansible/33741>\
**Category:** Ansible Project\
**Tags:** awx, kubernetes\
**Created:** [September 3, 2020, 11:48pm UTC](https://forum.ansible.com/t/help-generating-a-table-of-task-results-in-ansible/33741 "2020-09-03T23:48:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Piya\_Attapatto](https://avatars.discourse-cdn.com/v4/letter/p/edb3f5/32.png) [@Piya\_Attapatto](https://forum.ansible.com/u/Piya_Attapatto)\
**Post date:** [September 3, 2020, 11:48pm UTC](https://forum.ansible.com/t/help-generating-a-table-of-task-results-in-ansible/33741/1 "2020-09-03T23:48:09Z")

</div>

Hello devs,

First time posting here, apologies if not the done thing or the wrong place to post.

I’m not looking for a fix to an issue I’ve run into, rather I’m interested to know whether a strategy I’m thinking about sounds feasible or not, and whether there’s any recommendations on better approaches… let’s say I’m on a fact finding mission.

**Current state**  
I run some drift detection/correction & smoke tests from a scheduled ansible play, this play might include up to 20 tasks which get invoked by a main.yml. The schedule is run every hour against a few k8s clusters/endpoints/nodes by awx which posts a message via a slack webhook to tell me if the job ran or failed and posts some output too. The trouble is, I often have to look in awx or read some output, to tell me what happened when something went wrong.

That can take the form of stdout\_lines, ansible output etc but always results in me having to look at some output.

**Project Layout**

**.**  
**├── CHANGELOG.md**  
**├── README.md**  
**├── ansible.cfg**  
**├── inventory**  
**│ ├── dev.all.aws\_ec2.yaml**  
**│ ├── staging.all.aws\_ec2.yaml**  
**│ └── prod.all.aws\_ec2.yaml**  
**├── playbooks**  
**| ├── drift.yaml**  
**│ └── smoke\_tests.yaml**  
**└── tasks**  
**├── main.yaml**  
**├── check\_cluster\_health\_api.yaml**  
**├── check\_active\_passive\_cluster.yaml**  
**├── check\_dns.yaml**  
**├── check\_http\_statuses.yaml**  
**├── check\_internet\_connectivity.yaml**  
**├── check\_tcp\_ports.yaml**  
**├── check\_kube\_system\_pods.yaml**  
**├── check\_etcd\_cluster\_health.yaml**  
**…**

**Desired state**  
These tests already assert success or failure and if the job fails, I know some task failed. I’d like to capture the result of each task (say, 0 for success, 1 for fail), template something like an html table or ASCII table and then send that to slack instead.

**What main looks like**

---

<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:** [September 4, 2020, 4:52am UTC](https://forum.ansible.com/t/help-generating-a-table-of-task-results-in-ansible/33741/2 "2020-09-04T04:52:11Z")

</div>

Don't make the code more complex. Use ansible-runner to run the  
projects and analyse the potential problems from outside  
[https://ansible-runner.readthedocs.io/en/latest/](https://ansible-runner.readthedocs.io/en/latest/)

ansible-runner artifacts will provide you with all the details  
[https://ansible-runner.readthedocs.io/en/latest/intro.html#runner-artifacts-directory-hierarchy](https://ansible-runner.readthedocs.io/en/latest/intro.html#runner-artifacts-directory-hierarchy)  
See for example  
[https://gist.github.com/vbotka/31ccd5380a2b230be11b1df78cc402a1](https://gist.github.com/vbotka/31ccd5380a2b230be11b1df78cc402a1)

FWIW. See the example of a script how to run projects via  
ansible-runner and create simple log of what succeeded and failed  
[https://github.com/vbotka/ansible-runner/blob/master/contrib/ansible-cron-audit.bash](https://github.com/vbotka/ansible-runner/blob/master/contrib/ansible-cron-audit.bash)  
[https://github.com/vbotka/ansible-runner/blob/master/contrib/arwrapper.bash](https://github.com/vbotka/ansible-runner/blob/master/contrib/arwrapper.bash)

The idea is to run the script from cron and receive an email on  
failures only. The log can be scanned manually or sent to an external  
logging. If a playbook fails go to the ansible-runner artifacts and  
find the details. Next step might be the automation of the artifacts'  
analysis.

---

<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:** [September 4, 2020, 4:58am UTC](https://forum.ansible.com/t/help-generating-a-table-of-task-results-in-ansible/33741/3 "2020-09-04T04:58:50Z")

</div>

See "Ansible Runner Usage Examples"  
[https://ansible-runner-role.readthedocs.io/en/latest/guide.html#ansible-runner-usage-examples](https://ansible-runner-role.readthedocs.io/en/latest/guide.html#ansible-runner-usage-examples)
