# Stop displaying stdout when task fails

**URL:** <https://forum.ansible.com/t/stop-displaying-stdout-when-task-fails/26397>\
**Category:** Ansible Project\
**Created:** [December 31, 2017, 12:19am UTC](https://forum.ansible.com/t/stop-displaying-stdout-when-task-fails/26397 "2017-12-31T00:19:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Adolphson](https://avatars.discourse-cdn.com/v4/letter/a/e274bd/32.png) [@Adolphson](https://forum.ansible.com/u/Adolphson)\
**Post date:** [December 31, 2017, 12:19am UTC](https://forum.ansible.com/t/stop-displaying-stdout-when-task-fails/26397/1 "2017-12-31T00:19:47Z")

</div>

I have a task that sends a reboot command to a host, then pings every 10-seconds until a ping has failed. This indicates the hosts has begun the reboot and moves on the a ping every 60-seconds waiting for a ping success indicating the host is back up. It works fine with no issues. The only thing is the fatal output when the ping fails, I would like to stop this from displaying. i have no\_logs: true and ignore\_errors set already, but can not figure out how to stop the output.

**The code snippet:**

- name: Pause for Reboot to Begin. Checking Every 10-Seconds for Ping Failure.  
local\_action: raw ping -c 1 -W 1 {{vars[inventory\_hostname].IP\_Address}}  
register: output  
until: output.stdout.find(“0 received”) != -1  
retries: 12  
delay: 10  
ignore\_errors: true

- name: Waiting for Reboot to Complete. Checking Every 60-Seconds for Ping Success.  
local\_action: shell ping -c 1 {{vars[inventory\_hostname].IP\_Address}}  
register: result  
until: result.stdout.find(“64 bytes from”) != -1  
retries: 15  
delay: 60  
ignore\_errors: true

**The tasks output, want to suppress the red:**

TASK [base\_config\_oam : Send Reboot Command] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
changed: [vsrx-01]

TASK [base\_config\_oam : Pause for Reboot to Begin. Checking Every 10-Seconds for Ping Failure.] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
FAILED - RETRYING: Pause for Reboot to Begin. Checking Every 10-Seconds for Ping Failure. (12 retries left).  
FAILED - RETRYING: Pause for Reboot to Begin. Checking Every 10-Seconds for Ping Failure. (11 retries left).  
FAILED - RETRYING: Pause for Reboot to Begin. Checking Every 10-Seconds for Ping Failure. (10 retries left).  
FAILED - RETRYING: Pause for Reboot to Begin. Checking Every 10-Seconds for Ping Failure. (9 retries left).  
FAILED - RETRYING: Pause for Reboot to Begin. Checking Every 10-Seconds for Ping Failure. (8 retries left).  
FAILED - RETRYING: Pause for Reboot to Begin. Checking Every 10-Seconds for Ping Failure. (7 retries left).  
fatal: [vsrx-01 → localhost]: FAILED! =\> {“censored”: “the output has been hidden due to the fact that ‘no\_log: true’ was specified for this result”}

STDOUT:

PING 192.168.1.209 (192.168.1.209) 56(84) bytes of data.

— 192.168.1.209 ping statistics —  
1 packets transmitted, 0 received, 100% packet loss, time 0ms

MSG:

non-zero return code  
…ignoring

TASK [base\_config\_oam : Waiting for Reboot to Complete. Checking Every 60-Seconds for Ping Success.] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
FAILED - RETRYING: Waiting for Reboot to Complete. Checking Every 60-Seconds for Ping Success. (15 retries left).

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [December 31, 2017, 12:20pm UTC](https://forum.ansible.com/t/stop-displaying-stdout-when-task-fails/26397/2 "2017-12-31T12:20:01Z")

</div>

Why not just use the wait\_for\_connection[1] module that is designed for this?

[1] [https://docs.ansible.com/ansible/latest/wait\_for\_connection\_module.html](https://docs.ansible.com/ansible/latest/wait_for_connection_module.html)

---

<div class="post-metadata">

**Author:** ![Adolphson](https://avatars.discourse-cdn.com/v4/letter/a/e274bd/32.png) [@Adolphson](https://forum.ansible.com/u/Adolphson)\
**Post date:** [December 31, 2017, 10:08pm UTC](https://forum.ansible.com/t/stop-displaying-stdout-when-task-fails/26397/3 "2017-12-31T22:08:15Z")

</div>

I was reading about custom callbacks and modified the default stdout\_callback module to no display the fatal outputs.
