mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-28 05:11:25 -07:00
Expose loop_control.loop_var as ansible_loop_var (#54240)
* Expose the loop_var as ansible_loop_var * Add docs * fix assert test * Indicate version added
This commit is contained in:
parent
a5a7c7cb80
commit
6996926d89
6 changed files with 26 additions and 0 deletions
|
@ -319,6 +319,8 @@ class TaskExecutor:
|
|||
no_log = False
|
||||
items_len = len(items)
|
||||
for item_index, item in enumerate(items):
|
||||
task_vars['ansible_loop_var'] = loop_var
|
||||
|
||||
task_vars[loop_var] = item
|
||||
if index_var:
|
||||
task_vars[index_var] = item_index
|
||||
|
@ -376,6 +378,7 @@ class TaskExecutor:
|
|||
# now update the result with the item info, and append the result
|
||||
# to the list of results
|
||||
res[loop_var] = item
|
||||
res['ansible_loop_var'] = loop_var
|
||||
if index_var:
|
||||
res[index_var] = item_index
|
||||
if extended:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue