From e22bff5b76fd30c1d2f14e3e9a1f12a021ef89b6 Mon Sep 17 00:00:00 2001 From: Matt Martz Date: Mon, 13 Aug 2018 20:15:22 -0500 Subject: [PATCH] [2.5] Fix invocation output. Fixes #43447 (#43542) (#43647) * [2.5] Fix invocation output. Fixes #43447 (#43542) (cherry picked from commit 4094b01) Co-authored-by: Matt Martz * Add changelog for #43542 --- .../fragments/slack_callback_invocation.yaml | 2 ++ lib/ansible/plugins/callback/slack.py | 28 +++++++++---------- 2 files changed, 16 insertions(+), 14 deletions(-) create mode 100644 changelogs/fragments/slack_callback_invocation.yaml diff --git a/changelogs/fragments/slack_callback_invocation.yaml b/changelogs/fragments/slack_callback_invocation.yaml new file mode 100644 index 00000000000..b7303a76e1e --- /dev/null +++ b/changelogs/fragments/slack_callback_invocation.yaml @@ -0,0 +1,2 @@ +bugfixes: +- slack callback - Fix invocation by looking up data from cli.options (https://github.com/ansible/ansible/pull/43542) diff --git a/lib/ansible/plugins/callback/slack.py b/lib/ansible/plugins/callback/slack.py index 4638c1b743a..f53c68f4129 100644 --- a/lib/ansible/plugins/callback/slack.py +++ b/lib/ansible/plugins/callback/slack.py @@ -76,6 +76,8 @@ class CallbackModule(CallbackBase): super(CallbackModule, self).__init__(display=display) + self._options = cli.options + if not HAS_PRETTYTABLE: self.disabled = True self._display.warning('The `prettytable` python module is not ' @@ -132,27 +134,25 @@ class CallbackModule(CallbackBase): '*Playbook initiated* (_%s_)' % self.guid ] invocation_items = [] - if self._plugin_options and self.show_invocation: - tags = self.get_option('tags') - skip_tags = self.get_option('skip_tags') - extra_vars = self.get_option('extra_vars') - subset = self.get_option('subset') - inventory = os.path.basename( - os.path.realpath(self.get_option('inventory')) - ) - - invocation_items.append('Inventory: %s' % inventory) - if tags and tags != 'all': - invocation_items.append('Tags: %s' % tags) + if self._options and self.show_invocation: + tags = self._options.tags + skip_tags = self._options.skip_tags + extra_vars = self._options.extra_vars + subset = self._options.subset + inventory = [os.path.abspath(i) for i in self._options.inventory] + + invocation_items.append('Inventory: %s' % ', '.join(inventory)) + if tags and tags != ['all']: + invocation_items.append('Tags: %s' % ', '.join(tags)) if skip_tags: - invocation_items.append('Skip Tags: %s' % skip_tags) + invocation_items.append('Skip Tags: %s' % ', '.join(skip_tags)) if subset: invocation_items.append('Limit: %s' % subset) if extra_vars: invocation_items.append('Extra Vars: %s' % ' '.join(extra_vars)) - title.append('by *%s*' % self.get_option('remote_user')) + title.append('by *%s*' % self._options.remote_user) title.append('\n\n*%s*' % self.playbook_name) msg_items = [' '.join(title)]