2017-04-25 85 views
0

在Windows下面的步驟失敗在使用中複製文件,如果文件正在使用中:Ansible獲取失敗從Windows

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

ERROR

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

什麼是應對的最佳方法這個問題?

回答

0

您是否檢查過agent_log_dir變量是否包含尾部斜線?

comment from the Ansible modules core repository

假設您的目標是一個目錄,你需要在它尾部斜槓。在這種情況下,Linux提取將明確失敗(sans-trailing-slash會告訴你它是一個dir,並且結尾的斜槓將按照你的期望執行)。 Windows抓取無法在sans-trailing-slash情況下出錯,只是將文件下載到任何地方。

因此,假設情況如此,您需要在參數dest中設置一個斜線。

+0

鑑於它在寫入日誌的應用程序未運行時工作,我不認爲這是問題所在。 –