Files
eec57ec396 Misc callback fixes/cleanup (#85344)
* Misc callback fixes/cleanup

* Fix v1 callback method dispatch, fully deprecate v1 methods, add missing tests.
* Clean up callback plugin init/setup code, remove redundancies, improve error messaging.
* Remove unused callback method definitions from base class.

Co-authored-by: Matt Clay <matt@mystile.com>

* switch callback bypass to instance-level from class-level

* preserves any instance-level method magic that implementations were using

* add missing handler dispatch entry

* add tests to ensure all methods are covered

---------

Co-authored-by: Matt Clay <matt@mystile.com>
2025-06-16 20:03:06 -07:00

23 lines
656 B
Python

from __future__ import annotations
import os
import typing as t
from ansible.plugins.callback import CallbackBase
class CallbackModule(CallbackBase):
call_count: t.ClassVar[int] = 0
def v2_runner_on_ok(self, *args, **kwargs) -> None:
print(f"hello from ALWAYS ENABLED v2_runner_on_ok {args=} {kwargs=}")
CallbackModule.call_count += 1
def v2_playbook_on_stats(self, stats):
print('hello from ALWAYS ENABLED v2_playbook_on_stats')
if os.environ.get('_ASSERT_OOPS'):
assert CallbackModule.call_count < 2, "always enabled callback should not "
print("no double callbacks test PASS")