# Controlling the STDOUT/STDERR output of plays / suppressing output

**URL:** <https://forum.ansible.com/t/controlling-the-stdout-stderr-output-of-plays-suppressing-output/22400>\
**Category:** Ansible Project\
**Created:** [August 26, 2016, 5:46pm UTC](https://forum.ansible.com/t/controlling-the-stdout-stderr-output-of-plays-suppressing-output/22400 "2016-08-26T17:46:04Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![John\_Leo\_Huetter](https://avatars.discourse-cdn.com/v4/letter/j/6f9a4e/32.png) [@John\_Leo\_Huetter](https://forum.ansible.com/u/John_Leo_Huetter)\
**Post date:** [August 26, 2016, 5:46pm UTC](https://forum.ansible.com/t/controlling-the-stdout-stderr-output-of-plays-suppressing-output/22400/1 "2016-08-26T17:46:04Z")

</div>

Hello,

I am getting ready to have our general populace execute patches using Ansible. We are running playbooks with wrapper shell scripts at the moment and do not have Tower evaluated yet.

I would like to control what messages appears to them in the output of plays. Ansible is extremely verbose.

Not everyone understands the JSON formatting and anything “red” or with the “ERROR” string usually we get the hands thrown up and people question. We may have errors like if a directory does not exist, we create it, etc …

Anyway, I would like to hide the task output of plays which I choose because they do not match the when condition, or are skipped, or are superfluous.

I don’t want to send the whole of ansible-playbook to /dev/null and just have a return code. There are messages that are useful to them.

I also don’t want to go under the hood and hack with a callback\_plugin … I was hoping there was something out there already.

I am trying no\_log which prints this sarcastic message:

TASK [common : Initial check in] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ok: [hostA] =\> {“censored”: “the output has been hidden due to the fact that ‘no\_log: true’ was specified for this result”}  
ok: [hostB] =\> {“censored”: “the output has been hidden due to the fact that ‘no\_log: true’ was specified for this result”}

ok: [hostC] =\> {“censored”: “the output has been hidden due to the fact that ‘no\_log: true’ was specified for this result”}  
ok: [hostD] =\> {“censored”: “the output has been hidden due to the fact that ‘no\_log: true’ was specified for this result”}

Hilarious … Why print a message saying the output has been hidden?

Ok seriously how can you just not print this play to the screen AT ALL?

central:/app/sysint/bin\> ansible --version  
ansible 2.1.1.0  
config file = /etc/ansible/ansible.cfg  
configured module search path = Default w/o overrides

John

---

<div class="post-metadata">

**Author:** ![John\_Leo\_Huetter](https://avatars.discourse-cdn.com/v4/letter/j/6f9a4e/32.png) [@John\_Leo\_Huetter](https://forum.ansible.com/u/John_Leo_Huetter)\
**Post date:** [August 30, 2016, 5:19pm UTC](https://forum.ansible.com/t/controlling-the-stdout-stderr-output-of-plays-suppressing-output/22400/2 "2016-08-30T17:19:59Z")

</div>

Anyone … anyone … Bueller?

---

<div class="post-metadata">

**Author:** ![sivel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sivel/32/1198_2.png) [@sivel](https://forum.ansible.com/u/sivel)\
**Post date:** [August 30, 2016, 5:28pm UTC](https://forum.ansible.com/t/controlling-the-stdout-stderr-output-of-plays-suppressing-output/22400/3 "2016-08-30T17:28:52Z")

</div>

There is no built in way to achieve this. You could write your own `stdout` callback plugin that overrides the `_dump_results` method, to not display results when `no_log` was specified, and then register that callback plugin in your ansible.cfg file.

---

<div class="post-metadata">

**Author:** ![Bernhard\_L](https://avatars.discourse-cdn.com/v4/letter/b/7ba0ec/32.png) [@Bernhard\_L](https://forum.ansible.com/u/Bernhard_L)\
**Post date:** [August 30, 2016, 7:50pm UTC](https://forum.ansible.com/t/controlling-the-stdout-stderr-output-of-plays-suppressing-output/22400/4 "2016-08-30T19:50:22Z")

</div>

Hi,  
Some time ago I wrote a little awk-script to filter all output except errors to run playbooks via cronjob and only get emails if errors occured.  
It was just for exercising and I used only a few test cases, so it might work or not ;). I don’t use it in production, but perhaps it will help you.

Usage: ansible-playbook my\_playbook.yml | ansible\_silencer.sh

ansible\_silencer.sh:

#!/bin/bash  
awk ’ /^...ignoring/ { buffered=0 };  
{ if ( buffered==1 ) {  
if ( play\_printed==0 ) { print play; play\_printed=1; };  
if ( task\_printed==0 ) { print “\n” task; task\_printed=1; };  
if ( handler\_printed==0 ) { print “\n” handler; handler\_printed=1; };  
print linebuffer; buffered=0; };};  
/^PLAY/ { play=$0; play\_printed=0 };  
/^TASK/ { task=$0; task\_printed=0; handler\_printed=1 };  
/^RUNNING HANDLER/ { handler=$0; handler\_printed=0; task\_printed=1 };  
/^fatal:/ { linebuffer=$0; buffered=1 }; ’
