【发布时间】:2017-08-11 18:21:59
【问题描述】:
我有 3 个主机,AnsibleMast、DataRepo 和 Node,其中 Node 是 Ansible 的任意数量的目标。我试图让 Node 使用 rsync 从 DataRepo 获取文件。
如果我在 Node 上并执行此命令,文件将按预期传输:
rsync -avzL deployer@datarepo:/home/deployer/data/sbc/cbdbexport /tmp/.
我创建了这个任务:
- name: Copy the database backup file to the target node
command: 'rsync -azL deployer@datarepo:/home/deployer/data/sbc/cbdbexport /tmp/.'
执行时它只是挂起。我可以查看目标并验证它是否正在运行。
[deployer@steve ~]$ ps -ef | grep ssh
deployer 3778 3777 0 14:00 pts/2 00:00:00 ssh -l deployer datarepo rsync --server --sender -lLogDtprze.iLs . /home/deployer/data/sbc/cbdbexport
我使用同步模块创建了这个任务:
- name: Copy the database backup file to the target node
synchronize:
rsync_path: /usr/bin/rsync
mode: pull
src: rsync://datarepo:/home/deployer/data/sbc/cbdbexport
dest: /tmp/
archive: no
copy_links: yes
它最终会超时。当我执行 ps -ef | 时,它似乎也从未运行过grep ssh:
FAILED! => {"changed": false, "cmd": "/usr/bin/rsync --delay-updates -F --compress --copy-links --rsync-path=/usr/bin/rsync --out-format=<<CHANGED>>%i %n%L rsync://datarepo:/home/deployer/data/sbc/cbdbexport /tmp/", "failed": true, "msg": "rsync: failed to connect to datarepo: Connection timed out (110)\nrsync error: error in socket IO (code 10) at clientserver.c(124) [receiver=3.0.6]\n", "rc": 10}
在 Ansible 任务失败后,我测试我可以从 Node SSH 到 DataRepo 没有问题。我测试我可以运行原始 rysnc 命令。两者都按预期工作。
问题: 1. 为什么 Ansible 任务中的任何一个都失败了?有什么明显的东西我缺少让它像原始命令一样工作吗?
【问题讨论】: