# Using Copy module with delegation (Does not work for me)

**URL:** <https://forum.ansible.com/t/using-copy-module-with-delegation-does-not-work-for-me/13570>\
**Category:** Ansible Project\
**Created:** [September 27, 2013, 5:49pm UTC](https://forum.ansible.com/t/using-copy-module-with-delegation-does-not-work-for-me/13570 "2013-09-27T17:49:26Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kavin\_Kankeshwar](https://avatars.discourse-cdn.com/v4/letter/k/35a633/32.png) [@Kavin\_Kankeshwar](https://forum.ansible.com/u/Kavin_Kankeshwar)\
**Post date:** [September 27, 2013, 5:49pm UTC](https://forum.ansible.com/t/using-copy-module-with-delegation-does-not-work-for-me/13570/1 "2013-09-27T17:49:26Z")

</div>

Hi,

So i am trying to use the copy module along with delegation, It does not seem to work for me.

The reason why i am trying to use it this way is because the file is in Server X which does not have Ansible.

Is it a bug or a “feature”

- name: Copy file from xyz.server not local … inbound to others inbound  
copy: src=~/inbound/srch\_signal{{ SignalDate.stdout }}.tgz dest=~/inbound  
delegate\_to: xyz.server

If i do the same using rsync it works:

command: rsync -a inbound/srch\_signal{{ SignalDate.stdout }}.tgz {{ inventory\_hostname }}:inbound

Any ideas on this ?

---

<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:** [September 27, 2013, 5:56pm UTC](https://forum.ansible.com/t/using-copy-module-with-delegation-does-not-work-for-me/13570/2 "2013-09-27T17:56:06Z")

</div>

delegated copy will copy from master server (src) to the delegated server instead of the target server, it won’t copy from delegated server to target server if that is what you are expecting.

---

<div class="post-metadata">

**Author:** ![Kavin\_Kankeshwar](https://avatars.discourse-cdn.com/v4/letter/k/35a633/32.png) [@Kavin\_Kankeshwar](https://forum.ansible.com/u/Kavin_Kankeshwar)\
**Post date:** [September 27, 2013, 6:11pm UTC](https://forum.ansible.com/t/using-copy-module-with-delegation-does-not-work-for-me/13570/3 "2013-09-27T18:11:41Z")

</div>

Yes, i would expect delegate would mean that itself, it would run command on that machine instead of local/master server.

Because rsync seems to work :-s

---

<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:** [September 27, 2013, 6:49pm UTC](https://forum.ansible.com/t/using-copy-module-with-delegation-does-not-work-for-me/13570/4 "2013-09-27T18:49:44Z")

</div>

there is a big difference between copy and command, copy takes a ‘LOCAL’ file and sends it to the target, command runs a command AT the target.

when you delegate you always delegate the ‘target’ function, never the local.

---

<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 27, 2013, 8:31pm UTC](https://forum.ansible.com/t/using-copy-module-with-delegation-does-not-work-for-me/13570/5 "2013-09-27T20:31:12Z")

</div>

The opposite of copy, BTW, is fetch.

---

<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:** [September 27, 2013, 8:43pm UTC](https://forum.ansible.com/t/using-copy-module-with-delegation-does-not-work-for-me/13570/6 "2013-09-27T20:43:35Z")

</div>

but fetch would still just copy file from target/delegated machine to local, not between delegated and target.

---

<div class="post-metadata">

**Author:** ![Kavin\_Kankeshwar](https://avatars.discourse-cdn.com/v4/letter/k/35a633/32.png) [@Kavin\_Kankeshwar](https://forum.ansible.com/u/Kavin_Kankeshwar)\
**Post date:** [September 27, 2013, 8:52pm UTC](https://forum.ansible.com/t/using-copy-module-with-delegation-does-not-work-for-me/13570/7 "2013-09-27T20:52:47Z")

</div>

Yes, ☹ so I guess I’ll use rsync. Which does what I want it to do.

But it just seemed natural when you do a normal copy src is local destination is remote target, when you delegate src becomes delegated host. But I guess this applies to all modules except copy and fetch ?

---

<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:** [September 27, 2013, 8:58pm UTC](https://forum.ansible.com/t/using-copy-module-with-delegation-does-not-work-for-me/13570/8 "2013-09-27T20:58:18Z")

</div>

what you want is basically a 3 side copy, 1 initiator, 2 source and 3  
destination, in the copy module 1&2 currently must always be the same (for  
fetch its 1&3).

"command: rsync" will give you what you need, but it would be nicer to have  
something that works like get\_uri (3 pull from 2 and both can be diff from  
1) for copy and/or fetch. Not adding that to my list though, I already have  
a backlog I've been ignoring.

---

<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:** [September 27, 2013, 9:00pm UTC](https://forum.ansible.com/t/using-copy-module-with-delegation-does-not-work-for-me/13570/9 "2013-09-27T21:00:59Z")

</div>

You could still fetch and use the contents to do a copy with the content parameter if you really wanted to.

---

<div class="post-metadata">

**Author:** ![Kavin\_Kankeshwar](https://avatars.discourse-cdn.com/v4/letter/k/35a633/32.png) [@Kavin\_Kankeshwar](https://forum.ansible.com/u/Kavin_Kankeshwar)\
**Post date:** [September 27, 2013, 9:55pm UTC](https://forum.ansible.com/t/using-copy-module-with-delegation-does-not-work-for-me/13570/10 "2013-09-27T21:55:11Z")

</div>

I want to minimize data transfers as it’s large file. So I guess I’ll use delegate and rsync for now and will see if I send a pull request which would work more elegantly than rsync.
