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:
parent
694d6b339c
commit
068b9ac523
1 changed files with 6 additions and 1 deletions
|
@ -813,6 +813,9 @@ class TaskExecutor:
|
||||||
|
|
||||||
def _set_connection_options(self, variables, templar):
|
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
|
# create copy with delegation built in
|
||||||
final_vars = combine_vars(variables, variables.get('ansible_delegated_vars', dict()).get(self._task.delegate_to, dict()))
|
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'
|
# create dict of 'templated vars'
|
||||||
options = {'_extras': {}}
|
options = {'_extras': {}}
|
||||||
for k in option_vars:
|
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])
|
options[k] = templar.template(final_vars[k])
|
||||||
|
|
||||||
# add extras if plugin supports them
|
# add extras if plugin supports them
|
||||||
|
|
Loading…
Reference in a new issue