I was recently working on a long Ansible playbook that had a couple of unexpected things happening during
a run, and I needed to run it in "check" (or dry-run) mode
a whole bunch of times to figure out what it was going to change. To speed up the process, I wanted to
disable output of all non-changed
tasks, as reading back through thousands of lines of output every time
I ran it wasn't my idea of a good time.
It turns out to be really simple, although it took me a while to find the answer. There are two approaches, each of which may be useful depending on your situation. The first is to change your ansible.cfg and add or alter the following entries:
[defaults]
display_ok_hosts = no
display_skipped_hosts = no
The other approach, which was more suitable for my purposes, was to use environment variables. The simplest option for me in a ZSH shell was to prefix the command to set these two variables, as follows:
ANSIBLE_DISPLAY_OK_HOSTS=false ANSIBLE_DISPLAY_SKIPPED_HOSTS=false ansible-playbook my-playbook.yaml
This achieves exactly the same as altering ansible.cfg, but is easily reversible by just not prefixing when
you no longer need the command's output to be limited to only changed
tasks.
'til next time!
Alex