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
This commit is contained in:
Andrew Gaffney 2018-05-07 18:09:48 -05:00 committed by Brian Coca
parent bf1436ca52
commit 8e5956a98b
2 changed files with 5 additions and 0 deletions

View file

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

View file

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