Ansible Automation Platform – Fix ‘File Not Found’ in Synchronize Module

ansibleautomation

Recently we switched to Ansible automation platform 2.3. My execution environment is ee-supported-rhel8 which contains the Ansible.posix.synchronize module.

When I execute a synchronize module it is failing with:

"src: /tmp/memo.txt no such file".

It was running in Tower 1.2 without any issue.

    - Name: Install rsync on the Target
      package:
        name: rsync
        state: present
    
    - Name: Synchronize file from local to remote   
      synchronize:
         src: /tmp/memo.txt
         dest: /temp/test

Error

"cmd": "/usr/bin/rsync --delay-updates -F --compress --archive --rsh='/usr/bin/ssh -S none -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null' --out-format='<<CHANGED>>%i %n%L' /tmp/memo.txt root@xyz1234:/tmp/test",

"msg": "Warning: Permanently added 'xyz1234,148.168.65.73' (ECDSA) to the list of known hosts.
\r\nWARNING!\n This system,…
For additional information consult your local business's employee
privacy notice or contact your local Privacy Officer. \nrsync:
link_stat "/tmp/memo.txt" failed: No such file or directory (2)\nrsync error: some files/attrs were not transferred (see previous
errors) (code 23) at main.c(1189) [sender=3.1.3]\n",

I kept the source file in both control node and execution node it is still failing.

I also kept the source in a separate remote server. That is also failing. It is throwing error both source and target cannot be in remote.

Please suggest.

Best Answer

The error says:

rsync: link_stat "/tmp/memo.txt" failed: No such file or directory

Short answer: The file /tmp/memo.txt is missing on the controller.


Details: The first example shows how to use the module

- name: Synchronization of src on the control machine to dest on the remote hosts
  ansible.posix.synchronize:
    src: some/relative/path
    dest: /some/absolute/path

For example, the below play

- hosts: test_01

  tasks:

    - package:
        name: rsync

    - synchronize:
        src: /tmp/memo.txt
        dest: /tmp/test

synchronizes the file /tmp/memo.txt on the controller to the file /tmp/test on the remote host test_01. Given the file on the controller

shell> cat /tmp/memo.txt
test rsync

make sure the file is synchronized to the remote host

shell> ssh admin@test_01 cat /tmp/test
test rsync

The error can be reproduced by removing the file /tmp/memo.txt from the controller:

fatal: [test_01]: FAILED! => changed=false cmd: /usr/bin/rsync --delay-updates -F --compress --archive --rsh='/usr/bin/ssh -S none -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null' --rsync-path='sudo -u root rsync' --out-format='<>%i %n%L' /tmp/memo.txt admin@test_01:/tmp/test msg: |- Warning: Permanently added 'test_01' (ED25519) to the list of known hosts. rsync: [sender] link_stat "/tmp/memo.txt" failed: No such file or directory (2) rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1338) [sender=3.2.7] rc: 23

Related Topic