From 4aebefcf9e07ab875b7d93b0fc29a3e1ae05a14e Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Tue, 12 Oct 2021 05:07:26 +0000 Subject: [PATCH] Bugfix issue2692 logstash callbackmodule with no attribute options (#3530) (#3550) * Update logstash.py replacing _options with context.cliargs * Create 2692-logstash-callback-plugin-replacing_options logstash callback plugin replace _option with context.CLIARGS * Rename 2692-logstash-callback-plugin-replacing_options to 2692-logstash-callback-plugin-replacing_options.yml missed out the extenstion * Update logstash.py context imported * Update 2692-logstash-callback-plugin-replacing_options.yml dict to string * Update changelogs/fragments/2692-logstash-callback-plugin-replacing_options.yml Co-authored-by: Felix Fontein Co-authored-by: Felix Fontein (cherry picked from commit 7038812465678afd7b8df90ff78c41f719e0e535) Co-authored-by: Anand Victor --- ...692-logstash-callback-plugin-replacing_options.yml | 3 +++ plugins/callback/logstash.py | 11 ++++++----- 2 files changed, 9 insertions(+), 5 deletions(-) create mode 100644 changelogs/fragments/2692-logstash-callback-plugin-replacing_options.yml diff --git a/changelogs/fragments/2692-logstash-callback-plugin-replacing_options.yml b/changelogs/fragments/2692-logstash-callback-plugin-replacing_options.yml new file mode 100644 index 0000000000..ccf803598a --- /dev/null +++ b/changelogs/fragments/2692-logstash-callback-plugin-replacing_options.yml @@ -0,0 +1,3 @@ +--- +bugfixes: + - 'logstash callback plugin - replace ``_option`` with ``context.CLIARGS`` to fix the plugin on ansible-base and ansible-core (https://github.com/ansible-collections/community.general/issues/2692).' diff --git a/plugins/callback/logstash.py b/plugins/callback/logstash.py index 4c4fad8450..d34928ff34 100644 --- a/plugins/callback/logstash.py +++ b/plugins/callback/logstash.py @@ -94,6 +94,7 @@ ansible.cfg: | import os import json +from ansible import context import socket import uuid import logging @@ -152,11 +153,11 @@ class CallbackModule(CallbackBase): self.base_data['ansible_pre_command_output'] = os.popen( self.ls_pre_command).read() - if self._options is not None: - self.base_data['ansible_checkmode'] = self._options.check - self.base_data['ansible_tags'] = self._options.tags - self.base_data['ansible_skip_tags'] = self._options.skip_tags - self.base_data['inventory'] = self._options.inventory + if context.CLIARGS is not None: + self.base_data['ansible_checkmode'] = context.CLIARGS.get('check') + self.base_data['ansible_tags'] = context.CLIARGS.get('tags') + self.base_data['ansible_skip_tags'] = context.CLIARGS.get('skip_tags') + self.base_data['inventory'] = context.CLIARGS.get('inventory') def set_options(self, task_keys=None, var_options=None, direct=None): super(CallbackModule, self).set_options(task_keys=task_keys, var_options=var_options, direct=direct)