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

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 ?

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.

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

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.

The opposite of copy, BTW, is fetch.

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

Yes, :frowning: 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 ?

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.

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

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.