1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Use delegated vars for the delegated host name

In _process_pending_results (strategy/__init__.py), we were using the delegate_to
field directly from the original task, which was not being templated correctly.
As an alternate to #23599, this patch instead pulls the host name out of the delegated
vars passed back in the task result dictionary to avoid having to re-template things.

Fixes #23599
Fixes #20508
This commit is contained in:
James Cammarata 2017-05-16 09:20:40 -05:00
parent 9a958da57e
commit e5cd675b38

View file

@ -241,11 +241,13 @@ class StrategyBase:
return host_list
def get_delegated_hosts(self, result, task):
host_name = task.delegate_to
actual_host = self._inventory.get_host(host_name)
if actual_host is None:
actual_host = Host(name=host_name)
host_name = result.get('_ansible_delegated_vars', {}).get('ansible_host', None)
if host_name is not None:
actual_host = self._inventory.get_host(host_name)
if actual_host is None:
actual_host = Host(name=host_name)
else:
actual_host = Host(name=task.delegate_to)
return [actual_host]