mirror of https://github.com/ansible/ansible.git
Make it so callback plugins can act on implicit/explicit meta tasks (#71009)
Change: - Now sends meta tasks to the task start callback - Lets callback plugins opt-in to receiving implicit tasks Test Plan: - New integration tests Tickets: - Indirectly fixes #71007 by allowing custom callbacks with this data Signed-off-by: Rick Elrod <rick@elrod.me>pull/69107/head
parent
a1257d75aa
commit
ea58d7c233
@ -0,0 +1,2 @@
|
||||
minor_changes:
|
||||
- callback plugins - ``meta`` tasks now get sent to ``v2_playbook_on_task_start``. Explicit tasks are always sent. Plugins can opt in to receiving implicit ones.
|
@ -0,0 +1,23 @@
|
||||
# (c) 2020 Ansible Project
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
from ansible.plugins.callback import CallbackBase
|
||||
import os
|
||||
|
||||
|
||||
class CallbackModule(CallbackBase):
|
||||
CALLBACK_VERSION = 2.0
|
||||
CALLBACK_TYPE = 'stdout'
|
||||
CALLBACK_NAME = 'callback_meta'
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(CallbackModule, self).__init__(*args, **kwargs)
|
||||
self.wants_implicit_tasks = os.environ.get('CB_WANTS_IMPLICIT', False)
|
||||
|
||||
def v2_playbook_on_task_start(self, task, is_conditional):
|
||||
if task.implicit:
|
||||
self._display.display('saw implicit task')
|
||||
self._display.display(task.get_name())
|
Loading…
Reference in New Issue