首页 > 解决方案 > 如何使用ansible将文件从linux发送到windows服务器?

问题描述

我正在尝试将文件从 Linux 主机发送到我的 Windows 服务器。但是,我似乎无法让我的代码正常工作。我查看了文档,发现我必须使用该win_copy模块。虽然当我使用它时,什么都没有发生并且它失败了。我不确定我是在目标类别还是清单类别中指定主机。

代码:

   - name: Copy file to windows server
  win_copy:
    src: /home/robert
    dest: user@wvrp00002aa2.domain.name.com:C:\Users\username\Desktop

错误:

TASK [Copy files in windows systems] *******************************************************************************************************************************************************************
fatal: [11.110.60.000]: FAILED! => {"changed": false, "checksum": "euifnbf74895845ndej8dh733hd74gf7", "dest": "C:\\Users\\robert\\dev", "module_stderr": "Shared connection to 11.110.60.000 closed.\r\n", "module_stdout": "/bin/sh: powershell: command not found\r\n", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "operation": "file_copy", "original_basename": "text.txt", "rc": 127, "size": 20, "src": "/home/robert/text.txt"}

标签: ansible

解决方案


正确的缩进会有帮助吗?

  - name: Copy file to windows server
    win_copy:
      src: /home/robert
      dest: user@wvrp00002aa2.domain.name.com:C:\Users\username\Desktop

推荐阅读