Created
February 22, 2017 20:07
-
-
Save t2d/04b876d94e2fb298d40ebc6e8b4e2669 to your computer and use it in GitHub Desktop.
Remove skipped lines from ansible output
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/awk -f | |
# Remove skipped lines from ansible output | |
# Do only print plays and tasks with changes | |
# | |
# If you want to see warning: | |
# ansible-playbook site.yml 2>&1 | ansible-changeonly | |
# | |
# If you don't want to see warning: | |
# ansible-playbook site.yml 2>/dev/null | ansible-changeonly | |
# | |
# Mail all potential problems to root: | |
# ansible-playbook site.yml --check 2>&1 | ansible-changeonly | mail -E -s "Ansible not idempotent" root | |
# remember last TASK or HANDLER line | |
/^TASK/ { TL=$0; next } | |
/^RUNNING HANDLER/ { TL=$0; next } | |
# remember PLAY line, forget last TASK | |
/^PLAY / { PL=$0; TL=""; next } | |
# skip all uninteresting lines | |
/^skipping/ { next } | |
/^ok/ { next } | |
/^included/ { next } | |
/^$/ { next } | |
/changed=0/ { next } | |
/to retry, use/ { next } | |
/^$/ { next } | |
{ | |
# print PLAY line once | |
if ( PL != "" ) { | |
print "" | |
print PL | |
PL="" | |
} | |
# print TASK line once | |
if ( TL != "" ) { | |
print "" | |
print TL | |
TL="" | |
} | |
# print changed line | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment