# Customized error message on failed task?

**URL:** <https://forum.ansible.com/t/customized-error-message-on-failed-task/25374>\
**Category:** Ansible Project\
**Created:** [August 30, 2017, 7:13pm UTC](https://forum.ansible.com/t/customized-error-message-on-failed-task/25374 "2017-08-30T19:13:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![John\_Harmon](https://avatars.discourse-cdn.com/v4/letter/j/edb3f5/32.png) [@John\_Harmon](https://forum.ansible.com/u/John_Harmon)\
**Post date:** [August 30, 2017, 7:13pm UTC](https://forum.ansible.com/t/customized-error-message-on-failed-task/25374/1 "2017-08-30T19:13:22Z")

</div>

I have googled this, and found I am not the first to ask. I have the following:

`

- name: Check if NetworkManager is running  
shell: “systemctl status NetworkManager”  
register: nm\_status  
changed\_when: false  
ignore\_errors: yes  
when: ansible\_distribution\_major\_version == ‘7’  
`

When it errors out, thanks to systemd, there is a whole bunch of garbage. I would like the following instead  
msg: “NetworkManager not enabled”

I haven’t been able to get this to work yet with what I have googled… anyone else been able to do something like this?

---

<div class="post-metadata">

**Author:** ![John\_Harmon](https://avatars.discourse-cdn.com/v4/letter/j/edb3f5/32.png) [@John\_Harmon](https://forum.ansible.com/u/John_Harmon)\
**Post date:** [August 30, 2017, 7:17pm UTC](https://forum.ansible.com/t/customized-error-message-on-failed-task/25374/2 "2017-08-30T19:17:18Z")

</div>

I can suppress it with the following, but I haven’t been able to customize it

`no_log: true`

---

<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:** [August 30, 2017, 7:27pm UTC](https://forum.ansible.com/t/customized-error-message-on-failed-task/25374/3 "2017-08-30T19:27:46Z")

</div>

You would need to write you own callback plugin, or check the included ones to see if one of them suit your need.  
[https://github.com/ansible/ansible/tree/devel/lib/ansible/plugins/callback](https://github.com/ansible/ansible/tree/devel/lib/ansible/plugins/callback)
