Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added playbook and options info to callbacks #13412

Merged
merged 1 commit into from
Feb 18, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions lib/ansible/plugins/callback/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@

__all__ = ["CallbackBase"]

try:
from __main__ import cli
except ImportError:
# using API w/o cli
cli = False

class CallbackBase:

Expand All @@ -54,6 +59,11 @@ def __init__(self, display=None):
else:
self._display = global_display

if cli:
self._options = cli.options
else:
self._options = None

if self._display.verbosity >= 4:
name = getattr(self, 'CALLBACK_NAME', 'unnamed')
ctype = getattr(self, 'CALLBACK_TYPE', 'old')
Expand Down
13 changes: 13 additions & 0 deletions lib/ansible/plugins/callback/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,3 +230,16 @@ def v2_playbook_on_stats(self, stats):

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))