From dbab23e68f1c623f6ce4afdaf71d2d10c231d5e9 Mon Sep 17 00:00:00 2001 From: Chris Faulkner Date: Thu, 25 Aug 2016 10:22:27 -0700 Subject: [PATCH] Fix context_demo callback plugin. (#17235) --- lib/ansible/plugins/callback/context_demo.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/lib/ansible/plugins/callback/context_demo.py b/lib/ansible/plugins/callback/context_demo.py index f01f849406..126f55f7a9 100644 --- a/lib/ansible/plugins/callback/context_demo.py +++ b/lib/ansible/plugins/callback/context_demo.py @@ -32,21 +32,16 @@ class CallbackModule(CallbackBase): CALLBACK_NEEDS_WHITELIST = True def __init__(self, *args, **kwargs): + super(CallbackModule, self).__init__(*args, **kwargs) self.task = None self.play = None def v2_on_any(self, *args, **kwargs): - i = 0 - if self.play: - play_str = 'play: %s' % self.play.name - if self.task: - task_str = 'task: %s' % self.task - self._display.display("--- %s %s ---" % (self.play_str, self.task_str)) + self._display.display("--- play: {} task: {} ---".format(getattr(self.play, 'name', None), self.task)) self._display.display(" --- ARGS ") - for a in args: + for i, a in enumerate(args): self._display.display(' %s: %s' % (i, a)) - i += 1 self._display.display(" --- KWARGS ") for k in kwargs: