From 9767cda50746f79ba435be1e025e5b6cf487ed74 Mon Sep 17 00:00:00 2001 From: Kristian Heljas <11139388+kristianheljas@users.noreply.github.com> Date: Wed, 1 Jun 2022 17:10:59 +0300 Subject: [PATCH] Make `ignore_unreachable` to count `ignored` counter Fixes #77690 --- changelogs/fragments/77693-actually-ignore-unreachable.yml | 4 ++++ lib/ansible/plugins/callback/default.py | 3 +++ lib/ansible/plugins/strategy/__init__.py | 6 +++--- 3 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 changelogs/fragments/77693-actually-ignore-unreachable.yml diff --git a/changelogs/fragments/77693-actually-ignore-unreachable.yml b/changelogs/fragments/77693-actually-ignore-unreachable.yml new file mode 100644 index 00000000000..46abc8f8b8e --- /dev/null +++ b/changelogs/fragments/77693-actually-ignore-unreachable.yml @@ -0,0 +1,4 @@ +breaking_changes: + - >- + strategy plugins - Make ``ignore_unreachable`` to increase ``ignored`` and ``ok`` and counter, + not ``skipped`` and ``unreachable``. (https://github.com/ansible/ansible/issues/77690) diff --git a/lib/ansible/plugins/callback/default.py b/lib/ansible/plugins/callback/default.py index b9bfc8b8c6b..c5cc0e77ef5 100644 --- a/lib/ansible/plugins/callback/default.py +++ b/lib/ansible/plugins/callback/default.py @@ -130,6 +130,9 @@ class CallbackModule(CallbackBase): msg = "fatal: [%s]: UNREACHABLE! => %s" % (host_label, self._dump_results(result._result)) self._display.display(msg, color=C.COLOR_UNREACHABLE, stderr=self.get_option('display_failed_stderr')) + if result._task.ignore_unreachable: + self._display.display("...ignoring", color=C.COLOR_SKIP) + def v2_playbook_on_no_hosts_matched(self): self._display.display("skipping: no hosts matched", color=C.COLOR_SKIP) diff --git a/lib/ansible/plugins/strategy/__init__.py b/lib/ansible/plugins/strategy/__init__.py index 9c9846a997f..d1dadebf9cb 100644 --- a/lib/ansible/plugins/strategy/__init__.py +++ b/lib/ansible/plugins/strategy/__init__.py @@ -631,10 +631,10 @@ class StrategyBase: if not ignore_unreachable: self._tqm._unreachable_hosts[original_host.name] = True iterator._play._removed_hosts.append(original_host.name) + self._tqm._stats.increment('dark', original_host.name) else: - self._tqm._stats.increment('skipped', original_host.name) - task_result._result['skip_reason'] = 'Host %s is unreachable' % original_host.name - self._tqm._stats.increment('dark', original_host.name) + self._tqm._stats.increment('ok', original_host.name) + self._tqm._stats.increment('ignored', original_host.name) self._tqm.send_callback('v2_runner_on_unreachable', task_result) elif task_result.is_skipped(): self._tqm._stats.increment('skipped', original_host.name)