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” 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