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

2,751 views
Skip to first unread message

Kavin Kankeshwar

unread,
Sep 27, 2013, 1:49:26 PM9/27/13
to ansible...@googlegroups.com
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 ?

Regards,
--
Kavin.Kankeshwar

Brian Coca

unread,
Sep 27, 2013, 1:56:06 PM9/27/13
to ansible...@googlegroups.com
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.

Kavin Kankeshwar

unread,
Sep 27, 2013, 2:11:41 PM9/27/13
to ansible...@googlegroups.com
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

Regards,
--
Kavin.Kankeshwar



On Fri, Sep 27, 2013 at 10:56 AM, Brian Coca <bria...@gmail.com> wrote:
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.

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Brian Coca

unread,
Sep 27, 2013, 2:49:44 PM9/27/13
to ansible...@googlegroups.com
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.

Michael DeHaan

unread,
Sep 27, 2013, 4:31:12 PM9/27/13
to ansible...@googlegroups.com
The opposite of copy, BTW, is fetch.




On Fri, Sep 27, 2013 at 2:49 PM, Brian Coca <bria...@gmail.com> wrote:
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.

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



--
Michael DeHaan <mic...@ansibleworks.com>
CTO, AnsibleWorks, Inc.
http://www.ansibleworks.com/

Brian Coca

unread,
Sep 27, 2013, 4:43:35 PM9/27/13
to ansible...@googlegroups.com
but fetch would still just copy file from target/delegated machine to local, not between delegated and target.

Kavin Kankeshwar

unread,
Sep 27, 2013, 4:52:47 PM9/27/13
to ansible...@googlegroups.com, ansible...@googlegroups.com
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 ? 

Sent from my iPhone

On Sep 27, 2013, at 1:43 PM, Brian Coca <bria...@gmail.com> wrote:

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

--

Brian Coca

unread,
Sep 27, 2013, 4:58:18 PM9/27/13
to ansible...@googlegroups.com
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.

--
Brian Coca
Stultorum infinitus est numerus
0110000101110010011001010110111000100111011101000010000001111001011011110111010100100000011100110110110101100001011100100111010000100001
Pedo mellon a minno

Michael DeHaan

unread,
Sep 27, 2013, 5:00:59 PM9/27/13
to ansible...@googlegroups.com
You could still fetch and use the contents to do a copy with the content parameter if you really wanted to.




--

Kavin Kankeshwar

unread,
Sep 27, 2013, 5:55:11 PM9/27/13
to ansible...@googlegroups.com, ansible...@googlegroups.com
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. 

Sent from my iPhone
Reply all
Reply to author
Forward
0 new messages