# How to exclude files without extension to be parsed by ansible-playbook

**URL:** <https://forum.ansible.com/t/how-to-exclude-files-without-extension-to-be-parsed-by-ansible-playbook/42990>\
**Category:** Get Help\
**Created:** [May 23, 2025, 3:56pm UTC](https://forum.ansible.com/t/how-to-exclude-files-without-extension-to-be-parsed-by-ansible-playbook/42990 "2025-05-23T15:56:45Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![flotho](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/flotho/32/8592_2.png) [@flotho](https://forum.ansible.com/u/flotho)\
**Post date:** [May 23, 2025, 3:56pm UTC](https://forum.ansible.com/t/how-to-exclude-files-without-extension-to-be-parsed-by-ansible-playbook/42990/1 "2025-05-23T15:56:45Z")

</div>

Hi everyone,

I started using ansible a few years ago and still learning every days.  
At this time I’m working with hostvars as directory. Each host vars has a folder dedicated to datas.

```auto
hot_vars
  |- first_host
       |-data_folder
           - a_file_without_extension

```

When I run a playbook for this host, the file without extension is parsed by ansible-playbook .  
This cause some issue because files could be OS conf files or binary.

I would like to know how is it possible to exclude files without extension or place in a specfic path to be parsed by ansible.

I’ve found [ignore\_extensions](https://docs.ansible.com/ansible/latest/reference_appendices/config.html#inventory-ignore-exts) and I think most appropriate this one [ignore\_patterns](https://docs.ansible.com/ansible/latest/reference_appendices/config.html#inventory-ignore-patterns)

I tried multiple syntax on both without success.  
I’ve searched some examples and didn’t find something usefull.  
Maybe anyone could tell me what’s wrong with this `ignore_patterns=['data_folder']`

Any help would be appreciated.

Regards

---

<div class="post-metadata">

**Author:** ![utoddl](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/utoddl/32/249_2.png) [@utoddl](https://forum.ansible.com/u/utoddl)\
**Post date:** [May 23, 2025, 7:47pm UTC](https://forum.ansible.com/t/how-to-exclude-files-without-extension-to-be-parsed-by-ansible-playbook/42990/2 "2025-05-23T19:47:13Z")

</div>

Although I’ve never actually used the `ignore_patterns` or `ignore_extensions` configuration options, I will point out that their descriptions say

> List of (extensions|patterns) to ignore when using a directory as an **inventory source**.

However, you aren’t using these directories as an _inventory source_. You’re using them as variable sources. So I wouldn’t expect those options to have any effect on files in `./host_vars` or `./group_vars` directories.

There should not be any OS configuration or binary files in your `./host_vars` or `./group_vars` directories. Such files should be in a `./files` (or `./templates`) subdirectory, probably inside a role.

I’d also recommend against having any files under `./host_vars` or `./group_vars` that don’t have an extension of either `.yml` or `.yaml`. We used to do that, but quickly gave up the practice upon discovering that `ansible-lint` ignored any `./host_vars` or `./group_vars` files that had no such extension. (I don’t know whether that’s still the case, and I have no interest in finding out the hard way now.)

I’m curious what problems you’ve been attempting to solve by placing non-`vars` files in either `./host_vars` or `./group_vars`. If you’d care to tell us more about that, I and others here would be happy to suggest some more canonical ways to achieve your goals.

---

<div class="post-metadata">

**Author:** ![vbotka](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/vbotka/32/359_2.png) [@vbotka](https://forum.ansible.com/u/vbotka)\
**Post date:** [May 23, 2025, 9:27pm UTC](https://forum.ansible.com/t/how-to-exclude-files-without-extension-to-be-parsed-by-ansible-playbook/42990/3 "2025-05-23T21:27:52Z")

</div>

FWIW, files with a leading dot are ignored in _host\_vars_. A quick and dirty solution is to rename _a\_file\_without\_extension_ to _.a\_file\_without\_extension_

---

<div class="post-metadata">

**Author:** ![flotho](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/flotho/32/8592_2.png) [@flotho](https://forum.ansible.com/u/flotho)\
**Post date:** [May 25, 2025, 2:52pm UTC](https://forum.ansible.com/t/how-to-exclude-files-without-extension-to-be-parsed-by-ansible-playbook/42990/4 "2025-05-25T14:52:02Z")

</div>

Thanks @vbotka , to make it quick and dirty we renamed all our “problematic” folders with a leading dot.

---

<div class="post-metadata">

**Author:** ![flotho](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/flotho/32/8592_2.png) [@flotho](https://forum.ansible.com/u/flotho)\
**Post date:** [May 25, 2025, 2:56pm UTC](https://forum.ansible.com/t/how-to-exclude-files-without-extension-to-be-parsed-by-ansible-playbook/42990/5 "2025-05-25T14:56:11Z")

</div>

Thanks @utoddl , you’re definitively right, I read too fast.  
Those options were for inventory and not for variables.  
I read your recommendations and I think we still have a lot to do to improve our way to work with ansible.  
For the moment we’ll use the @vbotka proposal as a quick solution to achieve our goals.  
I’ll need to rethink all our variable/inventory structure 😉

A great thanks for your advices.

Regards
