mirror of
https://github.com/ansible/ansible.git
synced 2026-07-28 16:15:12 +02:00
* 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>
23 lines
656 B
Python
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")
|