# loop

**URL:** <https://forum.ansible.com/t/loop/30541>\
**Category:** Ansible Project\
**Created:** [June 12, 2019, 12:13pm UTC](https://forum.ansible.com/t/loop/30541 "2019-06-12T12:13:58Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![starflighter](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/starflighter/32/4992_2.png) [@starflighter](https://forum.ansible.com/u/starflighter)\
**Post date:** [June 12, 2019, 12:13pm UTC](https://forum.ansible.com/t/loop/30541/1 "2019-06-12T12:13:58Z")

</div>

Hi all,

how can I write with\_first\_found as loop?

I can’t find an example at [https://docs.ansible.com/ansible/devel/porting\_guides/porting\_guide\_2.5.html#migrating-from-with-x-to-loop](https://docs.ansible.com/ansible/devel/porting_guides/porting_guide_2.5.html#migrating-from-with-x-to-loop)

Can you give me an example?

Thanks,  
starflighter

---

<div class="post-metadata">

**Author:** ![ryad9200000](https://avatars.discourse-cdn.com/v4/letter/r/f04885/32.png) [@ryad9200000](https://forum.ansible.com/u/ryad9200000)\
**Post date:** [June 12, 2019, 12:39pm UTC](https://forum.ansible.com/t/loop/30541/2 "2019-06-12T12:39:30Z")

</div>

Hi,

You can see one exemple for loop :

```auto
- name: "with_list -> loop"
  debug:
    msg: "{{ item }}"
  loop:
    - my first word
    - my second word

```

When i execut this task, the result is :

[item=1] =\> my first word  
[item=2] =\> my second word

Do you understand ?

Regards,

---

<div class="post-metadata">

**Author:** ![Martin\_Krizek](https://avatars.discourse-cdn.com/v4/letter/m/d26b3c/32.png) [@Martin\_Krizek](https://forum.ansible.com/u/Martin_Krizek)\
**Post date:** [June 12, 2019, 1:02pm UTC](https://forum.ansible.com/t/loop/30541/3 "2019-06-12T13:02:41Z")

</div>

Hello,

you can find an example of using `first_found` with `loop` here:  
[https://docs.ansible.com/ansible/latest/user\_guide/playbooks\_conditionals.html#selecting-files-and-templates-based-on-variables](https://docs.ansible.com/ansible/latest/user_guide/playbooks_conditionals.html#selecting-files-and-templates-based-on-variables).

Thanks,  
Martin

---

<div class="post-metadata">

**Author:** ![starflighter](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/starflighter/32/4992_2.png) [@starflighter](https://forum.ansible.com/u/starflighter)\
**Post date:** [June 13, 2019, 5:38am UTC](https://forum.ansible.com/t/loop/30541/4 "2019-06-13T05:38:49Z")

</div>

Hi Martin,

that is what I was looking for.  
Thank you.

starflighter
