tested on python2.7 & 3.6
The following script uses python to parse an Ansible Tower log file into successes, failures, and unreachables by hostname. Ansible Tower jobs can run against large inventories and there are times that digging through the Play Recap can be a cumbersome task. This script is designed to remove human assessment and quickly return a summary of a job to the terminal or in an output file.
tested on Tower v3.0.3 & v3.2.3
ansibleLogParser.py -h
usage: ansibleLogParser.py [-h] -l LOGFILE [-c CRITERIA] [-o OUTPUT]
optional arguments:
-h, --help show this help message and exit
-l LOGFILE, --logfile LOGFILE
The log file that you want to parse
-c CRITERIA, --criteria CRITERIA
Whether you want to see "all" output parsed (default)
or only the "success", "failure", or "unreachable"
output
-o OUTPUT, --output OUTPUT
Additionally direct printed information to an output file
ansibleLogParser.py -l ansibleDiskmapLogTest.txt
Successes: 6
rhtudhtltapp.prod.redhat.com
rhtudhtltweb.prod.redhat.com
rhtudhtrmapp.prod.redhat.com
rhtudhtrmweb.prod.redhat.com
rhtudhuatapp.prod.redhat.com
rhtudhuatweb.prod.redhat.com
Failures: 4
rhtubtib23.prod.redhat.com
rhtubtib24.prod.redhat.com
rhtubtib25.prod.redhat.com
rhtudeip2.prod.redhat.com
Unreachable: 1
rhtubtib66.prod.redhat.com
ansibleLogParser.py -l ansibleDiskmapLogTest.txt -c success
Successes: 6
rhtudhtltapp.prod.redhat.com
rhtudhtltweb.prod.redhat.com
rhtudhtrmapp.prod.redhat.com
rhtudhtrmweb.prod.redhat.com
rhtudhuatapp.prod.redhat.com
rhtudhuatweb.prod.redhat.com
ansibleLogParser.py -l ansibleDiskmapLogTest.txt -c failure
Failures: 4
rhtubtib23.prod.redhat.com
rhtubtib24.prod.redhat.com
rhtubtib25.prod.redhat.com
rhtudeip2.prod.redhat.com
ansibleLogParser.py -l ansibleDiskmapLogTest.txt -c unreachable
Unreachable: 1
rhtubtib66.prod.redhat.com