# Have ansible manage the contents of a directory (including subdirectories)

**URL:** <https://forum.ansible.com/t/have-ansible-manage-the-contents-of-a-directory-including-subdirectories/17852>\
**Category:** Ansible Project\
**Created:** [March 26, 2015, 2:59pm UTC](https://forum.ansible.com/t/have-ansible-manage-the-contents-of-a-directory-including-subdirectories/17852 "2015-03-26T14:59:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mark\_Raider](https://avatars.discourse-cdn.com/v4/letter/m/b3f665/32.png) [@Mark\_Raider](https://forum.ansible.com/u/Mark_Raider)\
**Post date:** [March 26, 2015, 2:59pm UTC](https://forum.ansible.com/t/have-ansible-manage-the-contents-of-a-directory-including-subdirectories/17852/1 "2015-03-26T14:59:16Z")

</div>

I am having difficulty figuring out how to have ansible manage the content of a directory, including subdirectories.

For example…

if I have the following

example\_top\_level\_dir/  
 → subdir1  
 → subdir2

And I remove the subdir2 from Ansible…I want that reflected on the remote machine…Is there something similar to puppet’s “purge” where I can basically “sync” a reference directory in Ansible on a remote machine?

---

<div class="post-metadata">

**Author:** ![Mark\_Raider](https://avatars.discourse-cdn.com/v4/letter/m/b3f665/32.png) [@Mark\_Raider](https://forum.ansible.com/u/Mark_Raider)\
**Post date:** [March 26, 2015, 3:10pm UTC](https://forum.ansible.com/t/have-ansible-manage-the-contents-of-a-directory-including-subdirectories/17852/2 "2015-03-26T15:10:54Z")

</div>

Also should have included this in the initial post…I would prefer to not have to use the synchronize module as that requires rsync on both machines.
