remote copy issue

49 views
Skip to first unread message

Rene Paquin

unread,
Dec 1, 2021, 12:09:02 PM12/1/21
to ansible...@googlegroups.com

I am attemping o copy a file from one remote linux server to two remote linux servers.  My playbook is:

 

- name: copy file

  hosts: “remote source server”

  gather_facts: false

 

  tasks:

    - name: "copy "

      copy:

        src: /opt/odrive/alc/library/libraryusername.csv

        remote_src: yes

        dest: /var/alc

      delegate_to: destination server 1

      check_mode: yes

    - name: "copy "

      copy:

        src: /opt/odrive/alc/library/libraryusername.csv

        remote_src: yes

        dest: /var/alc

      delegate_to: destination server 2

      check_mode: yes

 

I get the following error despite the file being there.

"msg": "Source /opt/odrive/alc/library/libraryusername.csv not found"

 

What am I missing?

 

Thank you,

 

********************************
Rene Paquin - Systems Administrator
Wilfrid Laurier University
Waterloo, Ontario
(519)884-0710 x3795
rpa...@wlu.ca

 

dulh...@mailbox.org

unread,
Dec 1, 2021, 12:51:24 PM12/1/21
to ansible...@googlegroups.com
as far as I am aware of things delegate_to is located above the module name

  tasks:
    - name: "copy "
      delegate_to: destination server 1
      copy:
        src: /opt/odrive/alc/library/libraryusername.csv
        remote_src: yes
        dest: /var/alc
      check_mode: yes


I am still quite new to Ansible, so this is not founded on tons of experience though.
--
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/YQBPR0101MB62463290E15B126F8E6BF23AD8689%40YQBPR0101MB6246.CANPRD01.PROD.OUTLOOK.COM.

Rene Paquin

unread,
Dec 1, 2021, 12:57:25 PM12/1/21
to ansible...@googlegroups.com

Thank you for the response.  I made the change but still getting the same error.

 

Rene

To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/1322038778.164155.1638381066355%40office.mailbox.org.

* Notice: This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe.

Rene Paquin

unread,
Dec 1, 2021, 1:51:54 PM12/1/21
to ansible...@googlegroups.com

Further to this I created a quick check for file playbook as below and it does find it and displays the content successfully.  So the copy script is just not functional.  Any ideas as to why it does not find the file?

 

 

 

- name: check if file exists

  hosts: source server

  gather_facts: true

 

  tasks:

    - stat:

        path: /opt/odrive/alc/library

      register: result

    - slurp:

        src: /opt/odrive/alc/library/libraryusername.csv

      register: result

      when: result.stat.exists

    - debug:

        msg: "{{ result.content|b64decode }}"

Stefan Hornburg (Racke)

unread,
Dec 2, 2021, 4:41:42 AM12/2/21
to ansible...@googlegroups.com
On 01/12/2021 18:08, Rene Paquin wrote:
>
> I am attemping o copy a file from one remote linux server to two remote linux servers.  My playbook is:
>
> - name: copy file
>
>   hosts: “remote source server”
>
>   gather_facts: false
>
>   tasks:
>
>     - name: "copy "
>
>       copy:
>
>         src: /opt/odrive/alc/library/libraryusername.csv
>
>         remote_src: yes
>
>         dest: /var/alc
>
>       delegate_to: destination server 1
>
>       check_mode: yes
>
>     - name: "copy "
>
>       copy:
>
>         src: /opt/odrive/alc/library/libraryusername.csv
>
>         remote_src: yes
>
>         dest: /var/alc
>
>       delegate_to: destination server 2
>
>       check_mode: yes
>
> I get the following error despite the file being there.
>
> "msg": "Source /opt/odrive/alc/library/libraryusername.csv not found"
>
> What am I missing?
>
The copy module only supports the controller or target itself (remote_src) for the source file.

Take a look at the synchronize module if you want copy from one target to another.

Regards

            Racke

> ********************************
> Rene Paquin - Systems Administrator
> Wilfrid Laurier University
> Waterloo, Ontario
> (519)884-0710 x3795
> rpa...@wlu.ca <mailto:rpa...@wlu.ca>
>
> --
> 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/YQBPR0101MB62463290E15B126F8E6BF23AD8689%40YQBPR0101MB6246.CANPRD01.PROD.OUTLOOK.COM <https://groups.google.com/d/msgid/ansible-project/YQBPR0101MB62463290E15B126F8E6BF23AD8689%40YQBPR0101MB6246.CANPRD01.PROD.OUTLOOK.COM?utm_medium=email&utm_source=footer>.


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


OpenPGP_signature

Rene Paquin

unread,
Dec 2, 2021, 2:35:30 PM12/2/21
to ansible...@googlegroups.com
I have changed my playbook to use the sync module. But again I am getting errors. Check mode is so I can test before the actual sync. I am using the ansible.posix.synchronize module which I downloaded and installed.

Playbook
---
- name: copy file
hosts: source server
gather_facts: false

tasks:
- name: "copy libraryusername.csv from source to dest"
ansible.posix.synchronize:
src: "/opt/odrive/alc/library/libraryusername.csv"
dest: "rsync://destinationserver.wlu.ca/var/alc"
delegate_to: source server
check_mode: yes
...

The error I am getting is:

fatal: source server -> ictjobsub01.wlu.ca]: FAILED! => {"changed": false, "cmd": "/usr/bin/rsync --delay-updates -F --compress --dry-run --archive --out-format='<<CHANGED>>%i %n%L' /opt/odrive/alc/library/libraryusername.csv rsync://destinationserver/var/alc", "msg": "rsync: failed to connect to destinationserver (xx.xx.xx.xx): No route to host (113)\nrsync error: error in socket IO (code 10) at clientserver.c(125) [sender=3.1.2]\n", "rc": 10}

I can ssh from the source server to destination server and vice versa so not understanding the no route to host issue.

Thanks,
Rene

~

-----Original Message-----
From: ansible...@googlegroups.com <ansible...@googlegroups.com> On Behalf Of Stefan Hornburg (Racke)
Sent: December 2, 2021 4:42 AM
To: ansible...@googlegroups.com
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/7addf104-5064-0bce-0a39-09aed56c3d6a%40linuxia.de.
Reply all
Reply to author
Forward
0 new messages