# Counting and Displaying no of Successful and Failed Task in a playbook

**URL:** <https://forum.ansible.com/t/counting-and-displaying-no-of-successful-and-failed-task-in-a-playbook/27637>\
**Category:** Ansible Project\
**Created:** [May 26, 2018, 1:15pm UTC](https://forum.ansible.com/t/counting-and-displaying-no-of-successful-and-failed-task-in-a-playbook/27637 "2018-05-26T13:15:26Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vino\_B](https://avatars.discourse-cdn.com/v4/letter/v/839c29/32.png) [@Vino\_B](https://forum.ansible.com/u/Vino_B)\
**Post date:** [May 26, 2018, 1:15pm UTC](https://forum.ansible.com/t/counting-and-displaying-no-of-successful-and-failed-task-in-a-playbook/27637/1 "2018-05-26T13:15:26Z")

</div>

Hi All,

I have a play book, i need a help on how to display no of failed and successfull task as the out always ,

PLAY RECAP \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
server1 : ok=5 changed=0 unreachable=0 failed=0  
server2 : ok=5 changed=0 unreachable=0 failed=0

**Example:**

PLAY RECAP \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
server1 : ok=5 changed=0 unreachable=0 failed=0 task\_succeed=4 task\_failed=1  
server2 : ok=5 changed=0 unreachable=0 failed=0 task\_succeed=3 task\_failed=2

Tired the set as per the link “[https://stackoverflow.com/questions/49805434/ansible-increment-count-in-play-recap-for-failed-tasks-when-using-ignore-errors](https://stackoverflow.com/questions/49805434/ansible-increment-count-in-play-recap-for-failed-tasks-when-using-ignore-errors)” but no luck.

- hosts: all  
become: true  
become\_method: sudo  
gather\_facts: no  
vars:  
failed\_count: 0  
vars\_files:
- “/home/ansible/.ansible/target.yml”  
tasks:
- name: Check the status of Kerbros Service  
shell: /bin/systemctl status {{ item.tname }} | /usr/bin/head -1  
with\_items:
- { tname: ‘rpc-gssd.service’ }
- { tname: ‘rpc-svcgssd.service’ }
- { tname: ‘nfs-idmapd’ }  
register: kerbros\_status  
failed\_when: kerbros\_status.rc != 3  
changed\_when: false  
ignore\_errors: True  
tags: kerbros
- name: Increment variable  
set\_fact: failed\_count={{ failed\_count | int + 1 }}  
when: kerbros\_status.failed

From,  
Vino.B
