Customized error message on failed task?

13 views
Skip to first unread message

John Harmon

unread,
Aug 30, 2017, 3:13:22 PM8/30/17
to Ansible Project
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?

John Harmon

unread,
Aug 30, 2017, 3:17:18 PM8/30/17
to Ansible Project
I can suppress it with the following, but I haven't been able to customize it

no_log: true


Kai Stian Olstad

unread,
Aug 30, 2017, 3:28:21 PM8/30/17
to ansible...@googlegroups.com
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

--
Kai Stian Olstad
Reply all
Reply to author
Forward
0 new messages