# Get\_url with wildcards

**URL:** <https://forum.ansible.com/t/get-url-with-wildcards/4751>\
**Category:** Get Help\
**Created:** [April 5, 2024, 2:16pm UTC](https://forum.ansible.com/t/get-url-with-wildcards/4751 "2024-04-05T14:16:17Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![roelvandepaar](https://avatars.discourse-cdn.com/v4/letter/r/aeb1de/32.png) [@roelvandepaar](https://forum.ansible.com/u/roelvandepaar)\
**Post date:** [April 5, 2024, 2:16pm UTC](https://forum.ansible.com/t/get-url-with-wildcards/4751/1 "2024-04-05T14:16:17Z")

</div>

Hello,

I have problems downloading a file from a https repository.  
What is the best way to download a file where I don’t know the full file name?

Using wildcards `*` or regex (`[.*]`) in the url of the `get_url` module does not work.  
I can get the entire html of the url with the `uri` module, but then I would need a way to parse all that html to get a list of files.  
And then I would need to build a logic that selects the correct file.

The repository does not have an API. It is just a httpd repository.

How do you approach such a situation?

This is what I tried:

```auto
    - name: get_url module
      ansible.builtin.get_url:
        url: "https://my-domain.tld/mydir/*.md5"
        dest: .
        validate_certs: false

```

Regards  
Roel

---

<div class="post-metadata">

**Author:** ![Dustin](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/dustin/32/2573_2.png) [@Dustin](https://forum.ansible.com/u/Dustin)\
**Post date:** [April 5, 2024, 3:34pm UTC](https://forum.ansible.com/t/get-url-with-wildcards/4751/2 "2024-04-05T15:34:52Z")

</div>

Unfortunately, the get\_url module is not going to work this way. You will have to do the discovery of the full URLs yourself first, then loop over the discovered URLs.

---

<div class="post-metadata">

**Author:** ![flowerysong](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/flowerysong/32/2305_2.png) [@flowerysong](https://forum.ansible.com/u/flowerysong)\
**Post date:** [April 5, 2024, 6:59pm UTC](https://forum.ansible.com/t/get-url-with-wildcards/4751/3 "2024-04-05T18:59:20Z")

</div>

That’s simply not how HTTP is designed to work, regardless of what method you’re using for retrieval. You _have_ to know the full location of the resource you’re requesting.

---

<div class="post-metadata">

**Author:** ![roelvandepaar](https://avatars.discourse-cdn.com/v4/letter/r/aeb1de/32.png) [@roelvandepaar](https://forum.ansible.com/u/roelvandepaar)\
**Post date:** [April 8, 2024, 7:29am UTC](https://forum.ansible.com/t/get-url-with-wildcards/4751/4 "2024-04-08T07:29:23Z")

</div>

I guess you are correct.

I used a workaround and parsed the html of the repository with curl and bash commands to get the file names. Maybe if the repository had an API there would be a more straightforward way.

---

<div class="post-metadata">

**Author:** ![jpmens](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/jpmens/32/5543_2.png) [@jpmens](https://forum.ansible.com/u/jpmens)\
**Post date:** [April 8, 2024, 8:02am UTC](https://forum.ansible.com/t/get-url-with-wildcards/4751/5 "2024-04-08T08:02:20Z")

</div>

as long as you’re aware of how incredibly brittle and likely to break, that can be … if the repo software changes the way it presents their HTML, you might be up all night trying to figure out why your playbooks broke.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [May 8, 2024, 8:03am UTC](https://forum.ansible.com/t/get-url-with-wildcards/4751/6 "2024-05-08T08:03:04Z")

</div>

Closed on May 8, 2024, 8:03am UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
