From fb917d96ad5ae5b7cf00bab6a11545bff63df8d7 Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Wed, 3 Jan 2024 10:16:20 -0500 Subject: [PATCH] unreachable delegation fix --- lib/ansible/plugins/strategy/__init__.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/ansible/plugins/strategy/__init__.py b/lib/ansible/plugins/strategy/__init__.py index 4c5e352b17e..6adae52c4b2 100644 --- a/lib/ansible/plugins/strategy/__init__.py +++ b/lib/ansible/plugins/strategy/__init__.py @@ -630,9 +630,17 @@ class StrategyBase: elif task_result.is_unreachable(): ignore_unreachable = original_task.ignore_unreachable 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) + delegated_host = result.get('ansible_delegated_host', None) + if original_task.delegate_to is not None and delegated_host: + self._tqm._unreachable_hosts[delegated_host] = True + iterator._play._removed_hosts.append(delegated_host) + if origianl_host.name not in self._tqm._unreachable_hosts: + iterator.mark_host_failed(original_host) + self._tqm._stats.increment('failures', original_host.name) + else: + 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('ok', original_host.name) self._tqm._stats.increment('ignored', original_host.name)