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

keep track of original inventory hostname in play context (#38818)

this change further enables the ansible-vcr project to collect fixtures per host in
situations where the host context is totally lost due to delegation.

* Keep some original pre-delegate values in connection options
This commit is contained in:
jctanner 2018-04-16 17:16:57 -04:00 committed by Brian Coca
parent 694d6b339c
commit 068b9ac523

View file

@ -813,6 +813,9 @@ class TaskExecutor:
def _set_connection_options(self, variables, templar):
# Keep the pre-delegate values for these keys
PRESERVE_ORIG = ('inventory_hostname',)
# create copy with delegation built in
final_vars = combine_vars(variables, variables.get('ansible_delegated_vars', dict()).get(self._task.delegate_to, dict()))
@ -822,7 +825,9 @@ class TaskExecutor:
# create dict of 'templated vars'
options = {'_extras': {}}
for k in option_vars:
if k in final_vars:
if k in PRESERVE_ORIG:
options[k] = templar.template(variables[k])
elif k in final_vars:
options[k] = templar.template(final_vars[k])
# add extras if plugin supports them