【发布时间】:2017-08-29 15:40:20
【问题描述】:
我需要将一个目录从控制机器同步到控制机器(源和目标是本地主机)。我遵循指令here 并在脚本中添加了delegate_to: localhost。尽管如此,同步指令尝试使用远程机器作为目标并失败。
- name: Copy node_modules over if exists
synchronize:
src: "{{ node_modules_path }}"
dest: "{{ deploy_helper.new_release_path }}/{{ deploy_app_name }}/"
become: true
become_method: sudo
delegate_to: localhost
run_once: true
when: node_modules.stat.exists
这是输出:
致命:[panda -> panda.herokuapp.com]:失败! => {“改变”:假, "cmd": "/usr/bin/rsync --delay-updates -F --compress --archive --rsh 'ssh -S none -o StrictHostKeyChecking=no' --rsync-path=\"sudo rsync\" --out-format='%i %n%L' \"/root/node_modules/\" \"root@panda.herokuapp.com:/home/deploy/releases/20170404121408/\"", “失败”:真,“味精”:“\r\nrsync:mkdir \"/home/deploy/releases/20170404121408/\" 失败:没有这样的文件 或目录 (2)\nrsync 错误:文件 IO(代码 11)中的错误 main.c(605) [Receiver=3.0.9]\nrsync: 连接意外关闭 (9 到目前为止收到的字节数)[发件人]\nrsync 错误:rsync 协议中的错误 io.c(605) [sender=3.0.9]\n", "rc": 12}
处的数据流(代码 12)
Ansible 版本:ansible 2.2.1.0
很明显,Rsync 命令正在尝试同步到远程服务器而不是本地主机。我可以保证路径/home/deploy/releases/20170404121408/ 存在于本地主机上,但不存在于熊猫上。我错过了什么?
【问题讨论】:
-
@techraf 是的,我做到了。这是我特别引用的一段话:
# Synchronization of two paths both on the control machine - synchronize: src: some/relative/path dest: /some/absolute/path delegate_to: localhost -
@techraf src 是否是相对路径问题 - 在我的情况下 src 和 dest 都是绝对路径。我认为这不会影响行为,但很高兴尝试一下。
标签: python deployment ansible rsync ansible-2.x