From 30fae95efeec959be880800470459e0e58311a4b Mon Sep 17 00:00:00 2001 From: Chris Church Date: Thu, 15 May 2014 19:15:56 -0400 Subject: [PATCH 1/4] Change variable from pattern to name to correctly indicate what is being passed to the callback. --- lib/ansible/callback_plugins/noop.py | 2 +- lib/ansible/callbacks.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/ansible/callback_plugins/noop.py b/lib/ansible/callback_plugins/noop.py index 3d03ba55d6..5b7cf70562 100644 --- a/lib/ansible/callback_plugins/noop.py +++ b/lib/ansible/callback_plugins/noop.py @@ -89,7 +89,7 @@ class CallbackModule(object): def playbook_on_not_import_for_host(self, host, missing_file): pass - def playbook_on_play_start(self, pattern): + def playbook_on_play_start(self, name): pass def playbook_on_stats(self, stats): diff --git a/lib/ansible/callbacks.py b/lib/ansible/callbacks.py index cbd72b0591..78ff3ced99 100644 --- a/lib/ansible/callbacks.py +++ b/lib/ansible/callbacks.py @@ -695,9 +695,9 @@ class PlaybookCallbacks(object): display(msg, color='cyan') call_callback_module('playbook_on_not_import_for_host', host, missing_file) - def on_play_start(self, pattern): - display(banner("PLAY [%s]" % pattern)) - call_callback_module('playbook_on_play_start', pattern) + def on_play_start(self, name): + display(banner("PLAY [%s]" % name)) + call_callback_module('playbook_on_play_start', name) def on_stats(self, stats): call_callback_module('playbook_on_stats', stats) From 4e98e3785acee725b6f70f9f30d179b62662dd10 Mon Sep 17 00:00:00 2001 From: Chris Church Date: Thu, 15 May 2014 19:17:36 -0400 Subject: [PATCH 2/4] Reset play attribute on callback plugins when a play fails. --- lib/ansible/playbook/__init__.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/ansible/playbook/__init__.py b/lib/ansible/playbook/__init__.py index af28114a20..0232f5b86e 100644 --- a/lib/ansible/playbook/__init__.py +++ b/lib/ansible/playbook/__init__.py @@ -322,8 +322,9 @@ class PlayBook(object): ansible.callbacks.set_play(self.runner_callbacks, play) if not self._run_play(play): break - ansible.callbacks.set_play(self.callbacks, None) - ansible.callbacks.set_play(self.runner_callbacks, None) + + ansible.callbacks.set_play(self.callbacks, None) + ansible.callbacks.set_play(self.runner_callbacks, None) # summarize the results results = {} From 955dadf7431f184f249e7b1903c05f661c232908 Mon Sep 17 00:00:00 2001 From: Chris Church Date: Fri, 16 May 2014 00:49:11 -0400 Subject: [PATCH 3/4] Remove runner_on_error callback that is never used. --- lib/ansible/callback_plugins/noop.py | 3 --- lib/ansible/callbacks.py | 19 ------------------- plugins/callbacks/hipchat.py | 3 --- plugins/callbacks/log_plays.py | 3 --- plugins/callbacks/mail.py | 6 ------ plugins/callbacks/osx_say.py | 3 --- 6 files changed, 37 deletions(-) diff --git a/lib/ansible/callback_plugins/noop.py b/lib/ansible/callback_plugins/noop.py index 5b7cf70562..b5d5886874 100644 --- a/lib/ansible/callback_plugins/noop.py +++ b/lib/ansible/callback_plugins/noop.py @@ -41,9 +41,6 @@ class CallbackModule(object): def runner_on_ok(self, host, res): pass - def runner_on_error(self, host, msg): - pass - def runner_on_skipped(self, host, item=None): pass diff --git a/lib/ansible/callbacks.py b/lib/ansible/callbacks.py index 78ff3ced99..db1e3eedf3 100644 --- a/lib/ansible/callbacks.py +++ b/lib/ansible/callbacks.py @@ -343,9 +343,6 @@ class DefaultRunnerCallbacks(object): def on_ok(self, host, res): call_callback_module('runner_on_ok', host, res) - def on_error(self, host, msg): - call_callback_module('runner_on_error', host, msg) - def on_skipped(self, host, item=None): call_callback_module('runner_on_skipped', host, item=item) @@ -404,10 +401,6 @@ class CliRunnerCallbacks(DefaultRunnerCallbacks): display("%s | skipped" % (host), runner=self.runner) super(CliRunnerCallbacks, self).on_skipped(host, item) - def on_error(self, host, err): - display("err: [%s] => %s\n" % (host, err), stderr=True, runner=self.runner) - super(CliRunnerCallbacks, self).on_error(host, err) - def on_no_hosts(self): display("no hosts matched\n", stderr=True, runner=self.runner) super(CliRunnerCallbacks, self).on_no_hosts() @@ -534,18 +527,6 @@ class PlaybookRunnerCallbacks(DefaultRunnerCallbacks): display(msg, color='yellow', runner=self.runner) super(PlaybookRunnerCallbacks, self).on_ok(host, host_result) - def on_error(self, host, err): - - item = err.get('item', None) - msg = '' - if item: - msg = "err: [%s] => (item=%s) => %s" % (host, item, err) - else: - msg = "err: [%s] => %s" % (host, err) - - display(msg, color='red', stderr=True, runner=self.runner) - super(PlaybookRunnerCallbacks, self).on_error(host, err) - def on_skipped(self, host, item=None): if constants.DISPLAY_SKIPPED_HOSTS: msg = '' diff --git a/plugins/callbacks/hipchat.py b/plugins/callbacks/hipchat.py index a5acf9194e..6447a01e75 100644 --- a/plugins/callbacks/hipchat.py +++ b/plugins/callbacks/hipchat.py @@ -91,9 +91,6 @@ class CallbackModule(object): def runner_on_ok(self, host, res): pass - def runner_on_error(self, host, msg): - pass - def runner_on_skipped(self, host, item=None): pass diff --git a/plugins/callbacks/log_plays.py b/plugins/callbacks/log_plays.py index 8f037d6b1a..f329ce83b1 100644 --- a/plugins/callbacks/log_plays.py +++ b/plugins/callbacks/log_plays.py @@ -63,9 +63,6 @@ class CallbackModule(object): def runner_on_ok(self, host, res): log(host, 'OK', res) - def runner_on_error(self, host, msg): - log(host, 'ERROR', msg) - def runner_on_skipped(self, host, item=None): log(host, 'SKIPPED', '...') diff --git a/plugins/callbacks/mail.py b/plugins/callbacks/mail.py index 2281150f2c..ce1cda3942 100644 --- a/plugins/callbacks/mail.py +++ b/plugins/callbacks/mail.py @@ -66,12 +66,6 @@ class CallbackModule(object): body += 'A complete dump of the error:\n\n' + str(res) mail(sender=sender, subject=subject, body=body) - def runner_on_error(self, host, msg): - sender = '"Ansible: %s" ' % host - subject = 'Error: %s' % msg.strip('\r\n').split('\n')[0] - body = 'An error occured for host ' + host + ' with the following message:\n\n' + msg - mail(sender=sender, subject=subject, body=body) - def runner_on_unreachable(self, host, res): sender = '"Ansible: %s" ' % host if isinstance(res, basestring): diff --git a/plugins/callbacks/osx_say.py b/plugins/callbacks/osx_say.py index ec1f32bace..95a3f0d835 100644 --- a/plugins/callbacks/osx_say.py +++ b/plugins/callbacks/osx_say.py @@ -49,9 +49,6 @@ class CallbackModule(object): def runner_on_ok(self, host, res): say("pew", LASER_VOICE) - def runner_on_error(self, host, msg): - pass - def runner_on_skipped(self, host, item=None): say("pew", LASER_VOICE) From afbc7f8a0f344c0f82d07709a0da9f353c47f54a Mon Sep 17 00:00:00 2001 From: Chris Church Date: Tue, 1 Jul 2014 17:06:44 -0400 Subject: [PATCH 4/4] Change parameter from pattern to name for playbook_on_play_start in example callback plugins. --- plugins/callbacks/hipchat.py | 4 ++-- plugins/callbacks/log_plays.py | 2 +- plugins/callbacks/osx_say.py | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/plugins/callbacks/hipchat.py b/plugins/callbacks/hipchat.py index 6447a01e75..45c2e2c819 100644 --- a/plugins/callbacks/hipchat.py +++ b/plugins/callbacks/hipchat.py @@ -138,7 +138,7 @@ class CallbackModule(object): def playbook_on_not_import_for_host(self, host, missing_file): pass - def playbook_on_play_start(self, pattern): + def playbook_on_play_start(self, name): """Display Playbook and play start messages""" # This block sends information about a playbook when it starts @@ -167,7 +167,7 @@ class CallbackModule(object): # This is where we actually say we are starting a play self.send_msg("%s: Starting play: %s" % - (self.playbook_name, pattern)) + (self.playbook_name, name)) def playbook_on_stats(self, stats): """Display info about playbook statistics""" diff --git a/plugins/callbacks/log_plays.py b/plugins/callbacks/log_plays.py index f329ce83b1..dbe16b312c 100644 --- a/plugins/callbacks/log_plays.py +++ b/plugins/callbacks/log_plays.py @@ -108,7 +108,7 @@ class CallbackModule(object): def playbook_on_not_import_for_host(self, host, missing_file): log(host, 'NOTIMPORTED', missing_file) - def playbook_on_play_start(self, pattern): + def playbook_on_play_start(self, name): pass def playbook_on_stats(self, stats): diff --git a/plugins/callbacks/osx_say.py b/plugins/callbacks/osx_say.py index 95a3f0d835..174a03300f 100644 --- a/plugins/callbacks/osx_say.py +++ b/plugins/callbacks/osx_say.py @@ -97,8 +97,8 @@ class CallbackModule(object): def playbook_on_not_import_for_host(self, host, missing_file): pass - def playbook_on_play_start(self, pattern): - say("Starting play: %s" % pattern, HAPPY_VOICE) + def playbook_on_play_start(self, name): + say("Starting play: %s" % name, HAPPY_VOICE) def playbook_on_stats(self, stats): say("Play complete", HAPPY_VOICE)