我想通過ansible獲取已在windows節點上創建的文件(info.txt)。我試圖使用fetch模塊(它適用於我的linux節點),這似乎不適用於Windows客戶端。這裏是相關的代碼:如何使用Ansible從windows節點獲取文件
task:
-name: Fetch a info file
fetch: src=C:\info.txt dest=/home/user flat=yes
我得到沒有錯誤,但該文件沒有獲取。我在本地機器上運行ubuntu。難道我做錯了什麼?感謝
這裏是劇本運行的輸出與上-vvv選項:
If (Test-Path -PathType Leaf "C:\info.txt")
{
$sp = new-object -TypeName System.Security.Cryptography.SHA1CryptoServiceProvider;
$fp = [System.IO.File]::Open("C:\info.txt[System.IO.Filemode]::Open, [System.IO.FileAccess]::Read);
[System.BitConverter]::ToString($sp.ComputeHash($fp)).Replace("-", "").ToLower();
$fp.Dispose();
}
ElseIf (Test-Path -PathType Container "C:\info.txt")
{
Write-Host "3";
}
Else
{
Write-Host "1";
}
<192.168.122.123> FETCH "C:\info.txt" TO "/home/diego/work/ansible_win/ex1"
改變:[WIN1] => { 「改變」:真, 「校驗和」:NULL, 「DEST」: 「/ home/diego/work/ansible_win/ex1」,「invocation」:{「module_args」:{「dest」:「/ home/diego/work/ansible_win/ex1」,「flat」:「yes」,「src 「: 「C:/info.txt」}, 「MODULE_NAME」: 「取」}, 「的md5sum」:空, 「remote_checksum」: 「9664e0d22d3e184eb206d60af29e340f620092d0」, 「remote_md5sum」:空}
我認爲你需要改變你的'src'反斜槓爲斜槓,例如'C:/ info.txt'。 – Kev
試過了,那沒有什麼區別.. – diegus
什麼版本的可靠? – Kev