Ansible同步出模块错误

问题描述

我在MAC上运行Ansible 2.9.11。我创建了一个剧本来将一些预定义的freeswitch配置同步到新的Debian 10服务器。我已经安装了rsync并遵循了Ansible网站上的所有要求。当我运行同步任务时,它失败并显示以下消息。这是在剧本已经连接到盒子并执行其他任务(例如更新和安装必备组件)之后发生的。

错误

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
user1@1.1.1.127:/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}

任务:

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

解决方法

synchronize是rsync的包装,可以使您的剧本中的常见任务变得快速简便。 它已运行并且起源于运行Ansible的本地主机。当然,您可以只使用命令操作自己调用rsync,但还必须添加大量样板选项和主机事实。 syncnize并非旨在提供对rsync的全部功能的访问权限,但可以使最常见的调用更易于实现。根据您的用例,您仍然可能需要直接通过命令或shell调用rsync。

这意味着您无法在远程服务器中同步。