diff --git a/changelogs/fragments/59650-correctly-handler-delegate_to_hostname-loops.yaml b/changelogs/fragments/59650-correctly-handler-delegate_to_hostname-loops.yaml new file mode 100644 index 00000000000..efdaf13300c --- /dev/null +++ b/changelogs/fragments/59650-correctly-handler-delegate_to_hostname-loops.yaml @@ -0,0 +1,2 @@ +bugfixes: + - Correctly handle delegate_to hostnames in loops (https://github.com/ansible/ansible/issues/59650) diff --git a/lib/ansible/vars/manager.py b/lib/ansible/vars/manager.py index 3740e02afce..d529047811c 100644 --- a/lib/ansible/vars/manager.py +++ b/lib/ansible/vars/manager.py @@ -546,7 +546,7 @@ class VariableManager: if item is not None: vars_copy[item_var] = item - templar.set_available_variables = vars_copy + templar.available_variables = vars_copy delegated_host_name = templar.template(task.delegate_to, fail_on_undefined=False) if delegated_host_name != task.delegate_to: cache_items = True