Skip to content

Commit

Permalink
unixy Callback: Use Ansible's config manager (#5601)
Browse files Browse the repository at this point in the history
* unixy Callback: Use Ansible's config manager

In ansible-core 2.14 deprecated support was removed[1] for accessing options
of the DefaultCallback via class attributes. Use the "new" config system
instead.

[1]: ansible/ansible@dbdbfe8

Fixes #5600.

Signed-off-by: Fabian P. Schmidt <kerel@mailbox.org>

* Update changelog fragment.

Signed-off-by: Fabian P. Schmidt <kerel@mailbox.org>
Co-authored-by: Felix Fontein <felix@fontein.de>
  • Loading branch information
kerel-fs and felixfontein authored Nov 28, 2022
1 parent 1ca7752 commit 53da86c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- unixy callback plugin - fix plugin to work with ansible-core 2.14 by using Ansible's configuration manager for handling options (https://github.com/ansible-collections/community.general/issues/5600).
12 changes: 6 additions & 6 deletions plugins/callback/unixy.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def _get_task_display_name(self, task):

def _preprocess_result(self, result):
self.delegated_vars = result._result.get('_ansible_delegated_vars', None)
self._handle_exception(result._result, use_stderr=self.display_failed_stderr)
self._handle_exception(result._result, use_stderr=self.get_option('display_failed_stderr'))
self._handle_warnings(result._result)

def _process_result_output(self, result, msg):
Expand Down Expand Up @@ -109,7 +109,7 @@ def v2_playbook_on_play_start(self, play):
self._display.display(msg)

def v2_runner_on_skipped(self, result, ignore_errors=False):
if self.display_skipped_hosts:
if self.get_option('display_skipped_hosts'):
self._preprocess_result(result)
display_color = C.COLOR_SKIP
msg = "skipped"
Expand All @@ -128,7 +128,7 @@ def v2_runner_on_failed(self, result, ignore_errors=False):
msg += " | item: %s" % (item_value,)

task_result = self._process_result_output(result, msg)
self._display.display(" " + task_result, display_color, stderr=self.display_failed_stderr)
self._display.display(" " + task_result, display_color, stderr=self.get_option('display_failed_stderr'))

def v2_runner_on_ok(self, result, msg="ok", display_color=C.COLOR_OK):
self._preprocess_result(result)
Expand All @@ -142,7 +142,7 @@ def v2_runner_on_ok(self, result, msg="ok", display_color=C.COLOR_OK):
display_color = C.COLOR_CHANGED
task_result = self._process_result_output(result, msg)
self._display.display(" " + task_result, display_color)
elif self.display_ok_hosts:
elif self.get('display_ok_hosts'):
task_result = self._process_result_output(result, msg)
self._display.display(" " + task_result, display_color)

Expand All @@ -162,7 +162,7 @@ def v2_runner_on_unreachable(self, result):
display_color = C.COLOR_UNREACHABLE
task_result = self._process_result_output(result, msg)

self._display.display(" " + task_result, display_color, stderr=self.display_failed_stderr)
self._display.display(" " + task_result, display_color, stderr=self.get_option('display_failed_stderr'))

def v2_on_file_diff(self, result):
if result._task.loop and 'results' in result._result:
Expand Down Expand Up @@ -205,7 +205,7 @@ def v2_playbook_on_stats(self, stats):
colorize(u'ignored', t['ignored'], None)),
log_only=True
)
if stats.custom and self.show_custom_stats:
if stats.custom and self.get_option('show_custom_stats'):
self._display.banner("CUSTOM STATS: ")
# per host
# TODO: come up with 'pretty format'
Expand Down

0 comments on commit 53da86c

Please sign in to comment.