# loop\_var value not defined error

**URL:** <https://forum.ansible.com/t/loop-var-value-not-defined-error/34418>\
**Category:** Ansible Project\
**Created:** [January 11, 2021, 6:28am UTC](https://forum.ansible.com/t/loop-var-value-not-defined-error/34418 "2021-01-11T06:28:34Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mayank\_Goyal](https://avatars.discourse-cdn.com/v4/letter/m/94ad74/32.png) [@Mayank\_Goyal](https://forum.ansible.com/u/Mayank_Goyal)\
**Post date:** [January 11, 2021, 6:28am UTC](https://forum.ansible.com/t/loop-var-value-not-defined-error/34418/1 "2021-01-11T06:28:34Z")

</div>

Hi All,  
I am trying to access the variable using loop, but it’s not working for me.

playbook

---

<div class="post-metadata">

**Author:** ![Akasurde](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/akasurde/32/230_2.png) [@Akasurde](https://forum.ansible.com/u/Akasurde)\
**Post date:** [January 11, 2021, 6:47am UTC](https://forum.ansible.com/t/loop-var-value-not-defined-error/34418/2 "2021-01-11T06:47:44Z")

</div>

Hi Mayank,

loop\_var variable has a lifetime for a given task. It won’t be accessible after the task is complete.

Either you can use import\_tasks to club all related functionality or use `set_fact` like

- set\_fact:  
repo: “{{ repos[0] }}”

- debug: msg=“./{{ item.0 }}/{{ item.1 }}/{{ item.2 }}/{{ item.3 }}”  
with\_nested:

- “{{ repo.os\_list }}”

- “{{ repo.major\_distribution\_list }}”

- “{{ [repo.name](http://repo.name) }}”

- “{{ repo.archs }}”
