You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Ansible win_copy模块从Linux复制文件到Windows失败问题排查

Fixing Ansible win_copy "file does not exist" Error When Copying From Linux Controller to Windows

Let's break down why you're seeing this error and how to fix it:

1. Incorrect remote_src Parameter Usage

You've set remote_src: yes in your win_copy task, but this parameter tells Ansible to look for the source file on the remote Windows server, not your Linux control node. Since Windows doesn't use Linux-style paths like /home/app/..., Ansible can't find the file there.

When copying files from your control node to a Windows remote, you should omit remote_src entirely (it defaults to no, which means "source is on the control node") or explicitly set remote_src: no.

2. Mismatched Source File Path

Looking at your error log and the ls output:

  • Your task's src is set to /home/app/backup/1//de85cfa1-cb41-53ca-aba0-0e3dd728c27b//test.zip
  • But the actual file exists at /home/app/1//de85cfa1-cb41-53ca-aba0-0e3dd728c27b//test.zip

You have an extra backup directory in your task's source path, which is why Ansible can't locate the file.

Corrected Playbook Task

Here's the fixed version of your task, addressing both issues:

- name: Copy file to windows remote
  win_copy :
    src: "/home/app/1/de85cfa1-cb41-53ca-aba0-0e3dd728c27b/test.zip"
    dest: "c:/my_app_home/"

(Note: The double slashes // in your path work on Linux, but using single slashes / is more clean and standard.)

Additional Notes

  • If you ever need to copy a file between two locations on the Windows server itself, that's when you'd use remote_src: yes.
  • Always double-check that your src path matches exactly where the file lives on your Linux control node—even a single extra directory will cause this "file not found" error.

内容的提问来源于stack exchange,提问作者user63898

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.07 16:37:37