# with\_first\_found using a fileglob?

**URL:** <https://forum.ansible.com/t/with-first-found-using-a-fileglob/14067>\
**Category:** Ansible Project\
**Created:** [December 5, 2013, 4:32am UTC](https://forum.ansible.com/t/with-first-found-using-a-fileglob/14067 "2013-12-05T04:32:29Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gonzalo\_Servat](https://avatars.discourse-cdn.com/v4/letter/g/71c47a/32.png) [@Gonzalo\_Servat](https://forum.ansible.com/u/Gonzalo_Servat)\
**Post date:** [December 5, 2013, 4:32am UTC](https://forum.ansible.com/t/with-first-found-using-a-fileglob/14067/1 "2013-12-05T04:32:29Z")

</div>

Hi All,

I’d like to search a bunch of paths for the first “glob” match. For example:

- debug: msg=“{{ item }}”

with\_first\_found:

- files: “httpd-\*.rpm”

paths:

- RPMs/{{ ansible\_distribution\_version }}

- RPMs/{{ ansible\_distribution\_version }}.{{ ansible\_distribution\_release }}

I understand that the fileglob may match multiple files (by nature) but, in my case, I will only have one file that matches the pattern ‘httpd-\*.rpm’ and if I have multiple, I want to pick the first of the match in the ordered list of paths.

Essentially what I’m trying to achieve is uploading a distribution specific version of a file and the filename has a version number that changes over time, and I don’t want to store it in a variable.

Any ideas?

GS

---

<div class="post-metadata">

**Author:** ![Gonzalo\_Servat](https://avatars.discourse-cdn.com/v4/letter/g/71c47a/32.png) [@Gonzalo\_Servat](https://forum.ansible.com/u/Gonzalo_Servat)\
**Post date:** [December 8, 2013, 8:35pm UTC](https://forum.ansible.com/t/with-first-found-using-a-fileglob/14067/2 "2013-12-08T20:35:32Z")

</div>

Any suggestions?

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [December 9, 2013, 2:12pm UTC](https://forum.ansible.com/t/with-first-found-using-a-fileglob/14067/3 "2013-12-09T14:12:06Z")

</div>

Two options.

You can use with\_fileglob which will search one fileglob or you could enhance “with\_first\_found” to understand fileglobs.

---

<div class="post-metadata">

**Author:** ![Brian\_Coca1](https://avatars.discourse-cdn.com/v4/letter/b/278dde/32.png) [@Brian\_Coca1](https://forum.ansible.com/u/Brian_Coca1)\
**Post date:** [December 9, 2013, 3:28pm UTC](https://forum.ansible.com/t/with-first-found-using-a-fileglob/14067/4 "2013-12-09T15:28:01Z")

</div>

with\_pipe: find -name ‘glob’|head -n 1

---

<div class="post-metadata">

**Author:** ![Gonzalo\_Servat](https://avatars.discourse-cdn.com/v4/letter/g/71c47a/32.png) [@Gonzalo\_Servat](https://forum.ansible.com/u/Gonzalo_Servat)\
**Post date:** [December 9, 2013, 8:07pm UTC](https://forum.ansible.com/t/with-first-found-using-a-fileglob/14067/5 "2013-12-09T20:07:24Z")

</div>

Thanks Michael/Brian. Didn’t know about with\_pipe… will give that a try or I will look at modifying with\_first\_found.

- GS
