# recursive copy in v1.3

**URL:** <https://forum.ansible.com/t/recursive-copy-in-v1-3/13478>\
**Category:** Ansible Project\
**Created:** [September 14, 2013, 11:42pm UTC](https://forum.ansible.com/t/recursive-copy-in-v1-3/13478 "2013-09-14T23:42:26Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jason\_Harris](https://avatars.discourse-cdn.com/v4/letter/j/e9c0ed/32.png) [@Jason\_Harris](https://forum.ansible.com/u/Jason_Harris)\
**Post date:** [September 14, 2013, 11:42pm UTC](https://forum.ansible.com/t/recursive-copy-in-v1-3/13478/1 "2013-09-14T23:42:26Z")

</div>

I seem to recall seeing somewhere that v1.3 allowed some sort of recursive copying without resorting to a local command of rsync. But I can’t seem to find this again after looking again… Am I missing something or do we still need to use this workaround?

Thanks,  
Jason

---

<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:** [September 15, 2013, 3:36pm UTC](https://forum.ansible.com/t/recursive-copy-in-v1-3/13478/2 "2013-09-15T15:36:12Z")

</div>

Hi Jason,

local\_action: rsync is still the way to go.

It’s almost always going to be a better/faster option.

What we were talking about was the ‘synchronize’ module, a wrapper around rsync to make the playbooks read a bit cleaner, that was very nice but we didn’t quite get a quirk or two worked out in time to include it.

–Michael

---

<div class="post-metadata">

**Author:** ![Timothy\_Appnel](https://avatars.discourse-cdn.com/v4/letter/t/e5b9ba/32.png) [@Timothy\_Appnel](https://forum.ansible.com/u/Timothy_Appnel)\
**Post date:** [September 16, 2013, 3:33pm UTC](https://forum.ansible.com/t/recursive-copy-in-v1-3/13478/3 "2013-09-16T15:33:25Z")

</div>

This weekend I was working on integrating fixes to those quirks from smoothify. I’m not finished to submit a pull request but if you want to give it a try and test it out the branch is here:

[https://github.com/tima/ansible/tree/rsync3](https://github.com/tima/ansible/tree/rsync3)

---

<div class="post-metadata">

**Author:** ![Jason\_Harris](https://avatars.discourse-cdn.com/v4/letter/j/e9c0ed/32.png) [@Jason\_Harris](https://forum.ansible.com/u/Jason_Harris)\
**Post date:** [September 16, 2013, 7:38pm UTC](https://forum.ansible.com/t/recursive-copy-in-v1-3/13478/4 "2013-09-16T19:38:52Z")

</div>

Thanks!! I will give it a try shortly!

Cheers,  
Jas

---

<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:** [December 11, 2013, 7:08pm UTC](https://forum.ansible.com/t/recursive-copy-in-v1-3/13478/5 "2013-12-11T19:08:35Z")

</div>

Before the copy module supported it, you could do recursive copy, but it required multiple tasks.You could also use ansible pull and have an ‘agent’, which simplifies it enormously.

I know many tools offer recursive copy, but doing it right with permissions, sudo/su and multiple hosts is much harder than most realize. The current copy and syncronize modules go a long way, but don’t handle every possible case (and probably will never do), I haven’t found any tool that does so.

---

<div class="post-metadata">

**Author:** ![BrianAI](https://avatars.discourse-cdn.com/v4/letter/b/cab0a1/32.png) [@BrianAI](https://forum.ansible.com/u/BrianAI)\
**Post date:** [December 13, 2013, 8:35pm UTC](https://forum.ansible.com/t/recursive-copy-in-v1-3/13478/6 "2013-12-13T20:35:50Z")

</div>

Is this still with some issues?

I wanted to keep the src directory the “system of record” if you will…so that if I add / delete files from the ansible server i’m executing the playbook on, it will happen on the destination machine.  
I know I could use command: rsync or shell: rsync or whatever, but according to the ansible module page, it seems like synchronize should at least handle this:

> **3 - name: copy install pagages to server**  
> **4 synchronize: src=etc/server1/scripts/ dest=/etc/server1/scripts/**

I’m using this with roles, and from the error, it seems like it does not follow the same logic other things do with roles:

> **msg: rsync: change\_dir “/home/brian/Documents/scripts/ansible//etc/server1/scripts” failed: No such file or directory (2)**

seems like it doesn’t go into the “files” folder of the role it’s executing from, even though the ansible module speaks to relative paths.

Thoughts?

(From the ansible module website)

---

<div class="post-metadata">

**Author:** ![BrianAI](https://avatars.discourse-cdn.com/v4/letter/b/cab0a1/32.png) [@BrianAI](https://forum.ansible.com/u/BrianAI)\
**Post date:** [December 14, 2013, 4:11am UTC](https://forum.ansible.com/t/recursive-copy-in-v1-3/13478/7 "2013-12-14T04:11:14Z")

</div>

I’ve got it working by specifying the relative path to where i am running the playbook from, but synchronize seems to not follow the concept of “roles” (or it doesn’t reference file from the role directory that you’re in.

Any thoughts to that?

---

<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:** [December 14, 2013, 5:01pm UTC](https://forum.ansible.com/t/recursive-copy-in-v1-3/13478/8 "2013-12-14T17:01:29Z")

</div>

it’s possible that it doesn’t, since it’s new.

If you can share a minimal playbook to reproduce the problem of synchronize not knowing about the ‘files/’ subdirectory of a role, please file a ticket on GitHub and be sure to include the version of Ansible (should be x\>=1.4) that you’ve tested this on.

Thanks!

---

<div class="post-metadata">

**Author:** ![BrianAI](https://avatars.discourse-cdn.com/v4/letter/b/cab0a1/32.png) [@BrianAI](https://forum.ansible.com/u/BrianAI)\
**Post date:** [December 16, 2013, 3:20pm UTC](https://forum.ansible.com/t/recursive-copy-in-v1-3/13478/9 "2013-12-16T15:20:30Z")

</div>

Done and Done. Thanks!! 🙂

[https://github.com/ansible/ansible/issues/5307](https://github.com/ansible/ansible/issues/5307)

---

<div class="post-metadata">

**Author:** ![i\_iordanov](https://avatars.discourse-cdn.com/v4/letter/i/b3f665/32.png) [@i\_iordanov](https://forum.ansible.com/u/i_iordanov)\
**Post date:** [February 22, 2014, 10:55pm UTC](https://forum.ansible.com/t/recursive-copy-in-v1-3/13478/10 "2014-02-22T22:55:01Z")

</div>

Hey guys,

I just wanted to confirm that Ansible 1.4.4 still has this issue (synchronize not treating paths specified for src as relative to the role as I would expect).

Also, since this does keep coming up, I use the synchronize module in order to ensure files I delete on the local side also get removed on the remote side.

Cheers and thanks!  
iordan

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [February 24, 2014, 7:34pm UTC](https://forum.ansible.com/t/recursive-copy-in-v1-3/13478/11 "2014-02-24T19:34:06Z")

</div>

Thanks, we’re aware of synchronize not knowing about role paths entirely. There’s an open ticket on this. Something we need to sort out.
