mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-26 14:41:23 -07:00
Instantiate callback plugins only once so we can set play/task objects on them and they'll stick.
This commit is contained in:
parent
df93d7dd97
commit
53ac0bbec2
4 changed files with 113 additions and 16 deletions
|
@ -45,10 +45,25 @@ if cowsay and noncow == 'random':
|
|||
cows = out.split()
|
||||
cows.append(False)
|
||||
noncow = random.choice(cows)
|
||||
|
||||
callback_plugins = [x for x in utils.plugins.callback_loader.all()]
|
||||
|
||||
def set_play(callback, play):
|
||||
''' used to notify callback plugins of context '''
|
||||
callback.play = play
|
||||
for callback_plugin in callback_plugins:
|
||||
callback_plugin.play = play
|
||||
|
||||
def set_task(callback, task):
|
||||
''' used to notify callback plugins of context '''
|
||||
callback.task = task
|
||||
for callback_plugin in callback_plugins:
|
||||
callback_plugin.task = task
|
||||
|
||||
|
||||
def call_callback_module(method_name, *args, **kwargs):
|
||||
|
||||
for callback_plugin in utils.plugins.callback_loader.all():
|
||||
for callback_plugin in callback_plugins:
|
||||
methods = [
|
||||
getattr(callback_plugin, method_name, None),
|
||||
getattr(callback_plugin, 'on_any', None)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue