Transfer files from Server A to Server B

202 views
Skip to first unread message

Shivam Arora

unread,
Apr 7, 2021, 9:49:17 PM4/7/21
to Ansible Project
Hi Community Members, 

I am writing an Ansible playbook for which I want to copy files directly from Server A to Server B directly, skipping the Ansible node, i.e., I do not want to use Fetch and Copy module. I have tried the synchronize module to do the said task but however, it fails with the following error:
\"item\", \"changed\": false, \"cmd\": \"sshpass\", \"item\":ABC.csv \"msg\": \"[Errno 2] No such file or directory\", \"rc\": 2}​​​​​​\nfailed

If anyone has done something similar, can you guide us how we can accomplish this? Any help is appreciated.

Thanks
Shivam

Raja Natte

unread,
Apr 7, 2021, 10:06:37 PM4/7/21
to ansible...@googlegroups.com
Hi..

You can use fetch and  copy..  clean up on control node in same playbook . We are doing for  security files.. 

Thanks 

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/ba8c10fc-017b-4efe-8357-85aa98ba8d03n%40googlegroups.com.

Abdulrazzaq shaik

unread,
Sep 17, 2021, 1:55:51 PM9/17/21
to ansible...@googlegroups.com
Hi Raja 

Can you please share a sample playbook where you need to fetch files from one node and transfer those file to multiple nodes.



Stefan Hornburg (Racke)

unread,
Sep 18, 2021, 3:11:47 AM9/18/21
to ansible...@googlegroups.com
On 17/09/2021 20:55, Abdulrazzaq shaik wrote:
> Hi Raja
>
> Can you please share a sample playbook where you need to fetch files from one node and transfer those file to multiple nodes.
>
>

It looks like the sshpass binary is missing, probably on the controller.

Regards
Racke

>
> On Thu, Apr 8, 2021 at 7:36 AM Raja Natte <graj...@gmail.com <mailto:graj...@gmail.com>> wrote:
>
> Hi..
>
> You can use fetch and  copy..  clean up on control node in same playbook . We are doing for  security files..
> > Thanks
>
> On Wed, Apr 7, 2021, 9:49 PM Shivam Arora <shiva...@gmail.com <mailto:shiva...@gmail.com>> wrote:
>
> Hi Community Members,
>
> I am writing an Ansible playbook for which I want to copy files directly from Server A to Server B directly, skipping the Ansible node, i.e., I do not want to use Fetch and Copy module. I have tried the synchronize module to do the said task but however, it fails with the following error:
> \"item\", \"changed\": false, \"cmd\": \"sshpass\", \"item\":ABC.csv \"msg\": \"[Errno 2] No such file or directory\", \"rc\": 2}​​​​​​\nfailed
>
> If anyone has done something similar, can you guide us how we can accomplish this? Any help is appreciated.
>
> Thanks
> Shivam
>
> --
> 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 <mailto:ansible-proje...@googlegroups.com>.
> To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/ba8c10fc-017b-4efe-8357-85aa98ba8d03n%40googlegroups.com <https://groups.google.com/d/msgid/ansible-project/ba8c10fc-017b-4efe-8357-85aa98ba8d03n%40googlegroups.com?utm_medium=email&utm_source=footer>.
>
> --
> 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 <mailto:ansible-proje...@googlegroups.com>.
> To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CA%2BuTAOgZtk8o8h%2Bg%3DqmrezsUY7WUNaFrn%2BnWFNu85Gjww0gLWA%40mail.gmail.com <https://groups.google.com/d/msgid/ansible-project/CA%2BuTAOgZtk8o8h%2Bg%3DqmrezsUY7WUNaFrn%2BnWFNu85Gjww0gLWA%40mail.gmail.com?utm_medium=email&utm_source=footer>.
>
> --
> 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 <mailto:ansible-proje...@googlegroups.com>.
> To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CA%2B5G-C8p8_Dm720UvWQOtJHr4PLzAeOzNpCgw_Qa%2BS5_%3D9ywAQ%40mail.gmail.com <https://groups.google.com/d/msgid/ansible-project/CA%2B5G-C8p8_Dm720UvWQOtJHr4PLzAeOzNpCgw_Qa%2BS5_%3D9ywAQ%40mail.gmail.com?utm_medium=email&utm_source=footer>.


--
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration.

steve missoh

unread,
Sep 18, 2021, 7:09:12 PM9/18/21
to Ansible Project
Dear Raja,
do remember:
1. Use delegate_to in order to make synchronize module moves between managed nodes
2. from serverA to serverB you should ensure a connection mechanism is in place, preferably non interactive. For e.g. ssh passwordless

example playbook:
---
- hosts: se2
  tasks:
  - name: sync files between managed hosts
    synchronize:
          src: /tmp/foo
          dest: /tmp/bar
    delegate_to: se1


Reply all
Reply to author
Forward
0 new messages