Backport #39818 to stable-2.5 (#39824)

* Update vars for loop_control on each loop iteration (fixes #38899) (#39818)

(cherry picked from commit 01e8139d74)

* Changelog snippet for cherry-pick of #39818
pull/39839/merge
Andrew Gaffney 7 years ago committed by Brian Coca
parent bf1436ca52
commit 8e5956a98b

@ -0,0 +1,2 @@
bugfixes:
- loop_control - update template vars for loop_control fields on each loop iteration (https://github.com/ansible/ansible/pull/39818).

@ -302,6 +302,9 @@ class TaskExecutor:
if index_var: if index_var:
task_vars[index_var] = item_index task_vars[index_var] = item_index
# Update template vars to reflect current loop iteration
templar.set_available_variables(task_vars)
# pause between loop iterations # pause between loop iterations
if loop_pause and ran_once: if loop_pause and ran_once:
try: try:

Loading…
Cancel
Save