Any way to see ansible.builtin.debug messages while skipping OK hosts?

I normally run playbooks with display_ok_hosts = no as I don’t want to see a big list of tasks that didn’t do anything. That does mean that messages from ansible.builtin.debug tasks are also totally skipped.

If I do really want to show a message in the stdout of ansible-playbook while still skipping the printing of OK tasks, what are my options?

Do I need to use an entirely different custom stdout callback that knows to ignore OK tasks unless they are messages from debug? Is there a module other than ansible.builtin.debug I could use for the same purpose but it’s not treated as skippable debug?

Or, the display_ok_hosts = no is set in ansible.cfg so would setting that (to yes) as a parameter on the debug module override that for just that one debug message task?

You could use changed_when so it shows up based on some jinja2 expression Error handling in playbooks — Ansible Community Documentation.

2 Likes

Oh right, so if I always wanted a particular debug message to show up I could use changed_when: true and that would change the status of the task from “OK” to “changed” and it wouldn’t be skipped for display?

Update: Yes, this works nicely. Thanks!

1 Like