Search code examples
ansibledebianrsync

Ansible synchronize module errors out


I am running Ansible 2.9.11 on my MAC. I created a playbook to synchronize some pre-defined freeswitch configs to a new Debian 10 server. I have installed rsync and followed all the requirements on the Ansible site. When I run the sync task it fails with the following message. This happens after the playbook has already connected to the box and performed other tasks such as updating and installing prerequisites.

The error:

fatal: [dev-fs02b]: FAILED! => {"changed": false, "cmd": "sshpass -d3
/usr/bin/rsync --delay-updates -F --compress --archive
--rsh=/usr/bin/ssh -S none -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null --rsync-path=sudo rsync
--out-format=<<CHANGED>>%i %n%L /Users/User1/Documents/Ansible/files/sca
[email protected]:/etc/freeswitch", "msg": "Warning: Permanently added
'1.1.1.127' (ECDSA) to the list of known hosts.\r\nsudo: no tty
present and no askpass program specified\nrsync: connection
unexpectedly closed (0 bytes received so far) [sender]\nrsync error:
error in rsync protocol data stream (code 12) at
/AppleInternal/BuildRoot/Library/Caches/com.apple.xbs/Sources/rsync/rsync-54.120.1/rsync/io.c(453)
[sender=2.6.9]\n", "rc": 12}

The task:

  - name:  "Copies files over"
    synchronize:
      src: /Users/User1/Documents/Ansible/files/fs1
      dest: /etc/freeswitch
      recursive: yes

Solution

  • synchronize is a wrapper around rsync to make common tasks in your playbooks quick and easy. It is run and originates on the local host where Ansible is being run. Of course, you could just use the command action to call rsync yourself, but you also have to add a fair number of boilerplate options and host facts. synchronize is not intended to provide access to the full power of rsync, but does make the most common invocations easier to implement. You still may need to call rsync directly via command or shell depending on your use case.

    it mean you can not sync in remote server.