Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ansible Windows-在远程系统中复制_Windows_Ansible - Fatal编程技术网

Ansible Windows-在远程系统中复制

Ansible Windows-在远程系统中复制,windows,ansible,Windows,Ansible,我正在尝试使用Ansible从服务器上的一个位置复制到同一服务器上的另一个位置,例如“cp c:/users/foo c:/users/bar”,但找不到如何执行此操作,或者即使可能也找不到 有人能帮忙吗?使用“原始”模块并将命令直接发送到Powershell: 尽管它的描述,它可以用于windows Sérgio使用远程\u src:True 例如: 我不确定您有哪些使用案例,其中远程设备上的文件需要复制到其他位置,但Ansible主机上不能存在该文件。你能详细说明一下吗?@ydaetskc

我正在尝试使用Ansible从服务器上的一个位置复制到同一服务器上的另一个位置,例如“cp c:/users/foo c:/users/bar”,但找不到如何执行此操作,或者即使可能也找不到

有人能帮忙吗?

使用“原始”模块并将命令直接发送到Powershell:

尽管它的描述,它可以用于windows


Sérgio

使用
远程\u src:True

例如:


我不确定您有哪些使用案例,其中远程设备上的文件需要复制到其他位置,但Ansible主机上不能存在该文件。你能详细说明一下吗?@ydaetskcoR我们正在启动一个域中特定人员的ec2实例,主要用例是复制admin user文件夹,然后将其重命名为domain Users。我会将该文件夹放在S3上,然后使用win_get_url或一些PowerShell从中获取。他想在同一台服务器上复制文件,他为什么要使用远程复制?这是正确的答案
win\u copy
带有参数
remote\u src:True
。这很有效。如果你能更新这个答案的格式就更好了。(例如:对代码行使用单独的部分)。编辑:更新。
- name: Copy a single file where the source is on the remote host
  win_copy:
    src: C:\temp\foo.txt
    dest: C:\ansible\foo.txt
    remote_src: True