1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Merge pull request #13412 from bcoca/playbook_display

added playbook and options info to callbacks
This commit is contained in:
Brian Coca 2016-02-18 02:12:06 -08:00
commit 5948f8c6a2
2 changed files with 23 additions and 0 deletions

View file

@ -39,6 +39,11 @@ except ImportError:
__all__ = ["CallbackBase"] __all__ = ["CallbackBase"]
try:
from __main__ import cli
except ImportError:
# using API w/o cli
cli = False
class CallbackBase: class CallbackBase:
@ -54,6 +59,11 @@ class CallbackBase:
else: else:
self._display = global_display self._display = global_display
if cli:
self._options = cli.options
else:
self._options = None
if self._display.verbosity >= 4: if self._display.verbosity >= 4:
name = getattr(self, 'CALLBACK_NAME', 'unnamed') name = getattr(self, 'CALLBACK_NAME', 'unnamed')
ctype = getattr(self, 'CALLBACK_TYPE', 'old') ctype = getattr(self, 'CALLBACK_TYPE', 'old')

View file

@ -230,3 +230,16 @@ class CallbackModule(CallbackBase):
self._display.display("", screen_only=True) self._display.display("", screen_only=True)
def v2_playbook_on_start(self, playbook):
if self._display.verbosity > 1:
from os.path import basename
self._display.banner("PLAYBOOK: %s" % basename(playbook._file_name))
if self._display.verbosity > 3:
if self._options is not None:
for option in dir(self._options):
if option.startswith('_') or option in ['read_file', 'ensure_value', 'read_module']:
continue
val = getattr(self._options,option)
if val:
self._display.vvvv('%s: %s' % (option,val))