summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Cammarata <jimi@sngx.net>2017-05-16 09:20:40 -0500
committerJames Cammarata <jimi@sngx.net>2017-05-16 09:20:40 -0500
commit024593b1386199d074df36a2f89ab16314a41a0d (patch)
treeb3b8fae3ce6652f50b7e0435ee524d1df91b43d5
parentf240ba6b60f3dbd4a25b04a046ba53381747c000 (diff)
downloadansible-issue_20508_fixing_templated_delegate_to.tar.gz
Use delegated vars for the delegated host nameissue_20508_fixing_templated_delegate_to
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
-rw-r--r--lib/ansible/plugins/strategy/__init__.py12
1 files changed, 7 insertions, 5 deletions
diff --git a/lib/ansible/plugins/strategy/__init__.py b/lib/ansible/plugins/strategy/__init__.py
index 09fa6dbe86..3da92dde7f 100644
--- a/lib/ansible/plugins/strategy/__init__.py
+++ b/lib/ansible/plugins/strategy/__init__.py
@@ -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]