# Copy Directories

**URL:** <https://forum.ansible.com/t/copy-directories/13350>\
**Category:** Ansible Project\
**Created:** [August 22, 2013, 5:30pm UTC](https://forum.ansible.com/t/copy-directories/13350 "2013-08-22T17:30:12Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Furqan\_Hameed](https://avatars.discourse-cdn.com/v4/letter/f/5f8ce5/32.png) [@Furqan\_Hameed](https://forum.ansible.com/u/Furqan_Hameed)\
**Post date:** [August 22, 2013, 5:30pm UTC](https://forum.ansible.com/t/copy-directories/13350/1 "2013-08-22T17:30:12Z")

</div>

I still don’t understand why exactly there is no directory copying functionality available in ansible. Such a buzzkill. Am i missing something here? The work arounds are just over heads.

---

<div class="post-metadata">

**Author:** ![Patrick\_Regan](https://avatars.discourse-cdn.com/v4/letter/p/7cd45c/32.png) [@Patrick\_Regan](https://forum.ansible.com/u/Patrick_Regan)\
**Post date:** [August 22, 2013, 5:46pm UTC](https://forum.ansible.com/t/copy-directories/13350/2 "2013-08-22T17:46:15Z")

</div>

You are free to look at the code yourself and determine why.

[https://github.com/ansible/ansible/blob/devel/library/files/copy](https://github.com/ansible/ansible/blob/devel/library/files/copy)

There was a synchronization module that was found to have problems. You can check out the merging commit here  
[https://github.com/ansible/ansible/commit/aeb8649da54b880b45c92a0f0a227cf360184099](https://github.com/ansible/ansible/commit/aeb8649da54b880b45c92a0f0a227cf360184099)

---

<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:** [August 22, 2013, 9:32pm UTC](https://forum.ansible.com/t/copy-directories/13350/3 "2013-08-22T21:32:54Z")

</div>

Patrick,

I’m not sure I understand your comment – there’s nothing about the code that says recursive copy support couldn’t be implemented at some point.

Until then, shell out to rsync.

Rsync shouldn’t be hard for anyone, let me know what problems you are having.

Thanks!

–Michael

---

<div class="post-metadata">

**Author:** ![Patrick\_Regan](https://avatars.discourse-cdn.com/v4/letter/p/7cd45c/32.png) [@Patrick\_Regan](https://forum.ansible.com/u/Patrick_Regan)\
**Post date:** [August 23, 2013, 12:06pm UTC](https://forum.ansible.com/t/copy-directories/13350/4 "2013-08-23T12:06:48Z")

</div>

That was my point, but I should have made that more clear. My apologies.

---

<div class="post-metadata">

**Author:** ![Furqan\_Hameed](https://avatars.discourse-cdn.com/v4/letter/f/5f8ce5/32.png) [@Furqan\_Hameed](https://forum.ansible.com/u/Furqan_Hameed)\
**Post date:** [August 23, 2013, 12:40pm UTC](https://forum.ansible.com/t/copy-directories/13350/5 "2013-08-23T12:40:54Z")

</div>

I made a module using ` **distutils.dir_util.copy_tree** which recursively copy directories including the data. If anyone else need it i can improve and send in the pull request?`

---

<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:** [August 23, 2013, 12:45pm UTC](https://forum.ansible.com/t/copy-directories/13350/6 "2013-08-23T12:45:23Z")

</div>

It probably shouldn’t be a new module, but a patch on top of the copy module if, say, recurse=yes is specified.

---

<div class="post-metadata">

**Author:** ![Furqan\_Hameed](https://avatars.discourse-cdn.com/v4/letter/f/5f8ce5/32.png) [@Furqan\_Hameed](https://forum.ansible.com/u/Furqan_Hameed)\
**Post date:** [August 23, 2013, 12:54pm UTC](https://forum.ansible.com/t/copy-directories/13350/7 "2013-08-23T12:54:25Z")

</div>

i’ll look into it tonight. Was having trouble with md5sum for directories so separated it for time being. Will have to look 🙂

---

<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:** [August 23, 2013, 2:43pm UTC](https://forum.ansible.com/t/copy-directories/13350/8 "2013-08-23T14:43:41Z")

</div>

my current workaround is 2 copy tasks with the following:

with\_pipe: find {{path}} -type d

with\_pipe: find {{path}} -type f

first one creates directory tree structure, 2nd one copies files.
