Any one got a good callback plugin tutorial/documentation

159 views
Skip to first unread message

Stefan Coussens

unread,
Oct 6, 2022, 11:06:51 AM10/6/22
to Ansible Project
Hi,

I am trying to write a callback plugin. It is working quite well when all tasks succeed. However when a playbook has a failed task I get:


v2_runner_on_failed() got an unexpected keyword argument
'ignore_errors'

Code:

def v2_runner_on_failed(self, result):
  pass

I see a lot of plugins that have an extra argument , ignore_errors=False. But I can't figure out what this setting does. I think I need to have:

def v2_runner_on_failed(self, taskResult, ignore_errors=True):

I just want my playbook to continue and not stop because of the callback plugin.


Can anyone point me into the right direction

kind regards,

Stefan

Matt Martz

unread,
Oct 6, 2022, 11:11:10 AM10/6/22
to ansible...@googlegroups.com
In implementing callback methods, they have to adhere to the callback interface.

The `v2_runner_on_failed` method is defined as:


As such, your plugin has to accept the same arguments as defined there.

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/87aae087-700a-4fa9-8cfa-ce7b25c02886n%40googlegroups.com.


--
Matt Martz
@sivel
sivel.net

Brian Coca

unread,
Oct 6, 2022, 11:15:05 AM10/6/22
to ansible...@googlegroups.com
ignore_errors is used to 'report the error, but that we also ignored
the consequences of it' meaning that the task failed for the host but
that the host was not removed from 'active hosts'. the default
callback adds an 'ignoring error' message in this case.



--
----------
Brian Coca

Stefan Coussens

unread,
Oct 6, 2022, 11:26:20 AM10/6/22
to Ansible Project
Is it correct that I can just leave out the entire v2_runner_on_failed since the interface does the same thing (pass) and I do not need to override the method?

Matt Martz

unread,
Oct 6, 2022, 11:29:17 AM10/6/22
to ansible...@googlegroups.com
You only need to implement the methods you are concerned with. Omission of a method is allowed.

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.

Stefan Coussens

unread,
Oct 6, 2022, 11:36:19 AM10/6/22
to ansible...@googlegroups.com
Does this mean that when I would set  ignore_errors=True that the next task of that host would be executed? 



--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.

Stefan Coussens

unread,
Oct 6, 2022, 11:36:39 AM10/6/22
to ansible...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages