# Ansible delete files under a specific directory is failing

**URL:** <https://forum.ansible.com/t/ansible-delete-files-under-a-specific-directory-is-failing/29298>\
**Category:** Ansible Project\
**Tags:** ansible-project\
**Created:** [December 19, 2018, 9:56am UTC](https://forum.ansible.com/t/ansible-delete-files-under-a-specific-directory-is-failing/29298 "2018-12-19T09:56:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [December 19, 2018, 9:56am UTC](https://forum.ansible.com/t/ansible-delete-files-under-a-specific-directory-is-failing/29298/1 "2018-12-19T09:56:29Z")

</div>

This is expected as the ‘dest’ Parameter that you want to be absent is the webapps directory

I.E. it gets deleted

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [December 19, 2018, 10:24am UTC](https://forum.ansible.com/t/ansible-delete-files-under-a-specific-directory-is-failing/29298/2 "2018-12-19T10:24:30Z")

</div>

The only really reliable way to do this I found is to first register the actual files, filter them and then delete them

---

<div class="post-metadata">

**Author:** ![Karl\_Auer](https://avatars.discourse-cdn.com/v4/letter/k/cc9497/32.png) [@Karl\_Auer](https://forum.ansible.com/u/Karl_Auer)\
**Post date:** [December 19, 2018, 10:57am UTC](https://forum.ansible.com/t/ansible-delete-files-under-a-specific-directory-is-failing/29298/3 "2018-12-19T10:57:58Z")

</div>

Looks relevant:

[http://www.mydailytutorials.com/ansible-delete-multiple-files-directories-ansible/](http://www.mydailytutorials.com/ansible-delete-multiple-files-directories-ansible/)

Search in the page for “A better option” to find the right stuff.

I haven’t tested the techniques myself, though.

Regards, K.
