If you’ve used Ansible, you’re likely very familiar with this default output when a playbook runs a few tasks: the green indicates “ok” and unchanged, and the yellow indicates that a task has reported a change on the remote node.

Basic Ansible output

When we invoke ansible-playbook with a -v or two, the output becomes more verbose, and simultaneously quite difficult to read:

Debugging output

Serge tweeted something last night which I first looked at on a small mobile screen and didn’t really “see” as being interesting, but when I gave it another look this morning it made a lot of sense, and I want to demonstrate what that does.

Serge's tweet

I typically use a shell-script “wrapper” to invoke Ansible playbooks, and I keep that ./a shell script alongside the playbook. As “lazy” as I am, I typically alias a to ./a to further simplify my life. (And while we’re at it, I am not a friend of hash bangs and YAML files made executable because YAML isn’t executable.)

From today, as per what Serge suggests, my wrapper script looks like this:

#!/bin/sh

echo -n "$@" | grep -q -- "-v" && export ANSIBLE_STDOUT_CALLBACK=yaml

ansible-playbook test.yml "$@"

What that does is to detect I’ve invoked my wrapper with one or more -v (the grep is quiet) and then sets the stdout yaml callback , which produces much more readable output:

Debugging output with YAML

Thank you, Serge.