I have a Ansible play for PGBouncer that displays some output from a stats module built into PGBouncer.
My issue is that when Ansible prints the output to the terminal it mangles the newlines. Instead of seeing
----------
| OUTPUT |
----------
I see
----------\n| OUTPUT |\n----------
Does anyone know how to get Ansible to "pretty print" the output?
If you want more human friendly output define:
This will make ansible use the debug output module (previously named
human_log
) whinch despite its unfortunate name is less verbose and much easier to read by humans.If you get an error that this module is not available, upgrade Ansible or add this module locally if you cannot upgrade ansible, it will work with over versions of ansible like 2.0 or probaly even 1.9.
Another option to configure this is to add
stdout_callback = debug
to your ansible.cfgThere isn't a way to do what you want natively in Ansible. You can do this as a workaround:
Found this way in Ansible Project group forum:
We basically turn this into list by splitting it by newline and then printing that list.
You can use a callback plugin. This will re-parse your output and is easily turned on and off.
If you want to see it in a format that practically mimics standard output, you can use the
debug
callback plugin with thedebug
module in Ansible 2.7+ like this:If you're not running on parallel hosts, you can use the pause module:
Moves on without input by defining minutes or seconds but then user input is not captured.
Credit: https://github.com/ansible/ansible/issues/17446#issuecomment-245391682
Note: On parallel hosts, only output from the first host will be displayed
Despite this is not a concrete response, i've had the same problem within my team and we have implemented ara projet which is an open source software to make ansible human friendly.
You can check here a live demo.