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
sivel
(sivel)
October 6, 2022, 3:10pm
2
In implementing callback methods, they have to adhere to the callback interface.
The v2_runner_on_failed
method is defined as:
https://github.com/ansible/ansible/blob/4260b71cc77b7a44e061668d0d408d847f550156/lib/ansible/plugins/callback/init .py#L506
As such, your plugin has to accept the same arguments as defined there.
system
(system)
October 6, 2022, 3:13pm
3
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.
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?
sivel
(sivel)
October 6, 2022, 3:28pm
5
You only need to implement the methods you are concerned with. Omission of a method is allowed.
Does this mean that when I would set ignore_errors=True that the next task of that host would be executed?