From 8378ac30b34177e42b57dd65db18bee48c95d96c Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Tue, 26 Sep 2017 17:18:59 -0400 Subject: [PATCH] fix for slack callback breaks in 2.4 (#30932) * fix for slack callback breaks in 2.4 fixes #30838 --- lib/ansible/plugins/callback/slack.py | 29 +++++++++++---------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/lib/ansible/plugins/callback/slack.py b/lib/ansible/plugins/callback/slack.py index 0ac74de31ac..65e5b0b2195 100644 --- a/lib/ansible/plugins/callback/slack.py +++ b/lib/ansible/plugins/callback/slack.py @@ -54,7 +54,6 @@ except ImportError: cli = None from ansible.module_utils.urls import open_url -from ansible.module_utils.parsing.convert_bool import boolean from ansible.plugins.callback import CallbackBase try: @@ -75,13 +74,6 @@ class CallbackModule(CallbackBase): def __init__(self, display=None): - self.disabled = False - - if cli: - self._plugin_options = cli.options - else: - self._plugin_options = None - super(CallbackModule, self).__init__(display=display) if not HAS_PRETTYTABLE: @@ -90,7 +82,18 @@ class CallbackModule(CallbackBase): 'installed. Disabling the Slack callback ' 'plugin.') - self.webhook_url = self._plugin_options['webook_url'] + self.playbook_name = None + + # This is a 6 character identifier provided with each message + # This makes it easier to correlate messages when there are more + # than 1 simultaneous playbooks running + self.guid = uuid.uuid4().hex[:6] + + def set_options(self, options): + + super(CallbackModule, self).set_options(options) + + self.webhook_url = self._plugin_options['webhook_url'] self.channel = self._plugin_options['channel'] self.username = self._plugin_options['username'] self.show_invocation = (self._display.verbosity > 1) @@ -102,14 +105,6 @@ class CallbackModule(CallbackBase): 'the `SLACK_WEBHOOK_URL` environment ' 'variable.') - else: - self.playbook_name = None - - # This is a 6 character identifier provided with each message - # This makes it easier to correlate messages when there are more - # than 1 simultaneous playbooks running - self.guid = uuid.uuid4().hex[:6] - def send_msg(self, attachments): payload = { 'channel': self.channel,