# Possibility of copying directorys

**URL:** <https://forum.ansible.com/t/possibility-of-copying-directorys/12408>\
**Category:** Ansible Project\
**Created:** [February 23, 2013, 4:02pm UTC](https://forum.ansible.com/t/possibility-of-copying-directorys/12408 "2013-02-23T16:02:58Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![lars\_svenson](https://avatars.discourse-cdn.com/v4/letter/l/b782af/32.png) [@lars\_svenson](https://forum.ansible.com/u/lars_svenson)\
**Post date:** [February 23, 2013, 4:02pm UTC](https://forum.ansible.com/t/possibility-of-copying-directorys/12408/1 "2013-02-23T16:02:58Z")

</div>

Hi, I want to use the copy module to copy the whole content of a directory in a recursiv way to a path on a host.

With copy I get all the time error messages, but then I realized copy is just for single files. Is there any way to help me out?

I didn’t find a module or another way to do it with ansible.

cheers

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [February 23, 2013, 4:15pm UTC](https://forum.ansible.com/t/possibility-of-copying-directorys/12408/2 "2013-02-23T16:15:30Z")

</div>

One of the best ways is to just use "local\_action" to invoke rsync.

Copy may support recursive transfer in the near future.

---

<div class="post-metadata">

**Author:** ![lars\_svenson](https://avatars.discourse-cdn.com/v4/letter/l/b782af/32.png) [@lars\_svenson](https://forum.ansible.com/u/lars_svenson)\
**Post date:** [February 23, 2013, 4:51pm UTC](https://forum.ansible.com/t/possibility-of-copying-directorys/12408/3 "2013-02-23T16:51:26Z")

</div>

Thank you Michael

Would be great. It will make it pretty easy to install same software on different domains. And if this software available in git-repo just one kid to maintain.

Will try it with local\_action by now.

---

<div class="post-metadata">

**Author:** ![Yves\_Dorfsman](https://avatars.discourse-cdn.com/v4/letter/y/9de0a6/32.png) [@Yves\_Dorfsman](https://forum.ansible.com/u/Yves_Dorfsman)\
**Post date:** [February 23, 2013, 4:54pm UTC](https://forum.ansible.com/t/possibility-of-copying-directorys/12408/4 "2013-02-23T16:54:15Z")

</div>

The advantage of a recursive copy is that the status would only be "changed" if it is actually change, while command and shell always return a "changed" status.

---

<div class="post-metadata">

**Author:** ![Lester\_Wade](https://avatars.discourse-cdn.com/v4/letter/l/97f17d/32.png) [@Lester\_Wade](https://forum.ansible.com/u/Lester_Wade)\
**Post date:** [February 23, 2013, 5:41pm UTC](https://forum.ansible.com/t/possibility-of-copying-directorys/12408/5 "2013-02-23T17:41:10Z")

</div>

Should we file a feature request issue to track this?

local\_action is preferred here. A less savoury “hacky” method for if you have a top-level directory full of files (i.e. no deeper) may be to list the contents and register the output, then iterate through via with\_items and the copy module. I’ve not actually tried but perhaps it would work?

---

<div class="post-metadata">

**Author:** ![lars\_svenson](https://avatars.discourse-cdn.com/v4/letter/l/b782af/32.png) [@lars\_svenson](https://forum.ansible.com/u/lars_svenson)\
**Post date:** [February 23, 2013, 6:28pm UTC](https://forum.ansible.com/t/possibility-of-copying-directorys/12408/6 "2013-02-23T18:28:38Z")

</div>

yes please 🙂
