Skip to content

Commit ac2704c

Browse files
[PR #10566/14f706c5 backport][stable-9] merge_variables lookup: avoid deprecated Templar.set_temporary_context (#10567)
merge_variables lookup: avoid deprecated Templar.set_temporary_context (#10566) Avoid deprecated Templar.set_temporary_context. (cherry picked from commit 14f706c) Co-authored-by: Felix Fontein <[email protected]>
1 parent 018f4c9 commit ac2704c

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
bugfixes:
2+
- "merge_variables lookup plugin - avoid deprecated functionality from ansible-core 2.19 (https://github.com/ansible-collections/community.general/pull/10566)."

plugins/lookup/merge_variables.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,8 @@ def _merge_vars(self, search_pattern, initial_value, variables):
197197
result = initial_value
198198

199199
for var_name in var_merge_names:
200-
with self._templar.set_temporary_context(available_variables=variables): # tmp. switch renderer to context of current variables
201-
var_value = self._templar.template(variables[var_name]) # Render jinja2 templates
200+
temp_templar = self._templar.copy_with_new_env(available_variables=variables) # tmp. switch renderer to context of current variables
201+
var_value = temp_templar.template(variables[var_name]) # Render jinja2 templates
202202
var_type = _verify_and_get_type(var_value)
203203

204204
if prev_var_type is None:

0 commit comments

Comments
 (0)