# How to \*not\* print ansible diagnostic error messages?

**URL:** <https://forum.ansible.com/t/how-to-not-print-ansible-diagnostic-error-messages/25045>\
**Category:** Ansible Project\
**Created:** [July 21, 2017, 2:34pm UTC](https://forum.ansible.com/t/how-to-not-print-ansible-diagnostic-error-messages/25045 "2017-07-21T14:34:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Frank\_Thommen](https://avatars.discourse-cdn.com/v4/letter/f/7feea3/32.png) [@Frank\_Thommen](https://forum.ansible.com/u/Frank_Thommen)\
**Post date:** [July 21, 2017, 2:34pm UTC](https://forum.ansible.com/t/how-to-not-print-ansible-diagnostic-error-messages/25045/1 "2017-07-21T14:34:53Z")

</div>

Hi,

I have a playbook which executes a local task from which I need the exit status in later steps:

&nbsp;&nbsp;&nbsp;- name: Get exit status of ./run.sh  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;local\_action: command ./run.sh  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;register: ES  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ignore\_errors: yes

&nbsp;&nbsp;&nbsp;- name: Do something if ./run.sh failed  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;command:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;....  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;when: ES.rc == 1

Unfortunately when "./run.sh" fails, ansible prints a whole bunch of diagnostic output to the screen, which I am not interested in.

How can I tell ansible \*not\* to print diagnostic error output of a specific step?

We are running ansible 2.3.0 0 on CentOS 7

Cheers  
frank

---

<div class="post-metadata">

**Author:** ![Mike\_Eriksson](https://avatars.discourse-cdn.com/v4/letter/m/d6d6ee/32.png) [@Mike\_Eriksson](https://forum.ansible.com/u/Mike_Eriksson)\
**Post date:** [July 21, 2017, 2:40pm UTC](https://forum.ansible.com/t/how-to-not-print-ansible-diagnostic-error-messages/25045/2 "2017-07-21T14:40:40Z")

</div>

Frank,

Would adding the

no\_log: True

bit do what you’re after? That doesn’t remove all the text, but it cuts it down quite markedly.

In your example:

← Cut →

- name: Get exit status of ./run.sh  
local\_action: command ./run.sh  
register: ES  
ignore\_errors: yes  
no\_log: True  
 ← Cut → 

Cheers, Mike

---

<div class="post-metadata">

**Author:** ![azaghal](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/azaghal/32/4743_2.png) [@azaghal](https://forum.ansible.com/u/azaghal)\
**Post date:** [July 21, 2017, 3:17pm UTC](https://forum.ansible.com/t/how-to-not-print-ansible-diagnostic-error-messages/25045/3 "2017-07-21T15:17:36Z")

</div>

You could use "failed\_when: False" on the task. Although, keep in mind  
that would make the task treated as successful for all other purposes  
(e.g. ES.failed would be set to False).

Best regards

---

<div class="post-metadata">

**Author:** ![Frank\_Thommen](https://avatars.discourse-cdn.com/v4/letter/f/7feea3/32.png) [@Frank\_Thommen](https://forum.ansible.com/u/Frank_Thommen)\
**Post date:** [July 21, 2017, 3:41pm UTC](https://forum.ansible.com/t/how-to-not-print-ansible-diagnostic-error-messages/25045/4 "2017-07-21T15:41:23Z")

</div>

Hi
