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
pull/38793/merge
jctanner 7 years ago committed by Brian Coca
parent 694d6b339c
commit 068b9ac523

@ -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

Loading…
Cancel
Save