Ansible提取无法从Windows复制正在使用的文件



如果文件正在使用:

- name: copy MyLog.log
  fetch:
    src: "C:\MyLog.log"
    dest: "{{ agent_log_dir }}"
    flat: yes
    validate_checksum: no

错误

The process cannot access the file 'C:\MyLog.log' because it is 
being used by rnanother process.""rnAt li

解决此问题的最佳方法是什么?

您是否检查了agent_log_dir变量是否包含落后斜线?

评论来自Ansible模块核心存储库:

假设您的DIR是DIR,您需要在其上进行拖延。在这种情况下,Linux Fetch将明确失败(Sans-Trailing-Slash会告诉您这是DIR,而Taild Slash将执行您的期望(。Windows获取未在Sans-Trailing-slash案件上出错,只是将文件下载到无处。

因此,假设这里是这种情况,您需要在dest参数中设置尾斜线。

最新更新