I’m using the Ansible “fetch” module to fetch a file from the remote Windows Server machine, but the file never arrives on the control machine (works when Linux is the remote machine though)
Configuration:
Control machine: Ansible 2.01 running on Amazon Linux
Target machine is Windows Server 2012R2
I’m trying to fetch a 70mbyte zip file using this code:
`
-
name: fetch deliverable
fetch: src=“{{ topleveldir }}\ult_{{ hostvars[‘localhost’][‘version’] }}{{ hostvars[‘localhost’][‘soft’] }}{{ hostvars[‘localhost’][‘target’] }}.zip” dest=/home/ec2-user/files flat=yes fail_on_missing=yes -
name: Output the name of the archive
debug: msg=“archive - ult_{{ hostvars[‘localhost’][‘version’] }}{{ hostvars[‘localhost’][‘soft’] }}{{ hostvars[‘localhost’][‘target’] }}.zip”
`
The output suggests that it succeeds, but the file never arrives on the control machine (when the target is a Linux server, the file arrives fine, btw).
I’ve searched the entire control machine and can’t find the file. The file is on the target machine, though, at C:\apps\ult_master_noc_win2012.zip
Here is the output with the middle part (encoded file?) removed — any ideas what’s going on here?
`
TASK [fetch deliverable] *******************************************************
task path: /build_scripts/build_noc_cust_win.yml:204
<52.36.54.12> ESTABLISH WINRM CONNECTION FOR USER: Administrator on PORT 5986 TO 52.36.54.12
<52.36.54.12> WINRM CONNECT: transport=ssl endpoint=https://52.36.54.12:5986/wsman
<52.36.54.12> EXEC Set-StrictMode -Version Latest
If (Test-Path -PathType Leaf “C:\apps\ult_master_noc_win2012.zip”)
{
$sp = new-object -TypeName System.Security.Cryptography.SHA1CryptoServiceProvider;
$fp = [System.IO.File]::Open(“C:\apps\ult_master_noc_win2012.zip”, [System.IO.Filemode]::Open, [System.IO.FileAccess]::Read);
[System.BitConverter]::ToString($sp.ComputeHash($fp)).Replace(“-”, “”).ToLower();
$fp.Dispose();
}
ElseIf (Test-Path -PathType Container “C:\apps\ult_master_noc_win2012.zip”)
{
Write-Host “3”;
}
Else
{
Write-Host “1”;
}
<52.36.54.12> WINRM OPEN SHELL: E5D85769-78F7-40DF-9A5F-B98304A49455
<52.36.54.12> WINRM EXEC u’PowerShell’ [u’-NoProfile’, u’-NonInteractive’, u’-ExecutionPolicy’, u’Unrestricted’, u’-EncodedCommand’, u’UwBlAHQALQBTAHQAcgBpAGMAdABNAG8AZABlACAALQBWAGUAcgBzAGkAbwBuACAATABhAHQAZQBzAHQACgBJAGYAIAAoAFQAZQBzAHQALQBQAGEAdABoACAALQBQAGEAdABoAFQAeQBwAGUAIABMAGUAYQBmACAAIgBDADoAXABjAGEAcABzAGUAbgB0AGEAXAB1AGwAdAByAGEAdwByAGEAcABfAG0AYQBzAHQAZQByAF8AbgBvAGUAdABsAF8AdwBpAG4AMgAwADEAMgAuAHoAaQBwACIAKQAKAHsACgAkAHMAcAAgAD0AIABuAGUAdwAtAG8AYgBqAGUAYwB0ACAALQBUAHkAcABlAE4AYQBtAGUAIABTAHkAcwB0AGUAbQAuAFMAZQBjAHUAcgBpAHQAeQAuAEMAcgB5AHAAdABvAGcAcgBhAHAAaAB5AC4AUwBIAEEAMQBDAHIAeQBwAHQAbwBTAGUAcgB2AGkAYwBlAFAAcgBvAHYAaQBkAGUAcgA7AAoAJABmAHAAIAA9ACAAWwBTAHkAcwB0AGUAbQAuAEkATwAuAEYAaQBsAGUAXQA6dABhAFwAdQBsAHQAcgBhAHcAcgBhAHAAXwBtAGEAcwB0AGUAcgBfAG4AbwBlAHQAbABfAHcAaQBuADIAMAAxADIALgB6AGkAcAAiACwAIABbAFMAeQBzAHQAZQBtAC4ASQBPAC4ARgBpAGwAZQBtAG8AZABlAF0AOgA6AE8AcABlAG4ALAAgAFsAUwB5AHMAdABlAG0ALgBJAE8ALgBGAGkAbABlAEEAYwBjAGUAcwBzAF0AOgA6AFIAZQBhAGQAKQA7AAoAWwBTAHkAcwB0AGUAbQAuAEIAaQB0AEMAbwBuAHYAZQByAHQAZQByAF0AOgA6AFQAbwBTAHQAcgBpAG4AZwAoACQAcwBwAC4AQwBvAG0AcAB1AHQAZQBIAGEAcwBoACgAJABmAHAAKQApAC4AUgBlAHAAbABhAGMAZQAoACIALQAiACwAIAAiACIAKQAuAFQAbwBMAG8AdwBlAHIAKAApADsACgAkAGYAcAAuAEQAaQBzAHAAbwBzAGUAKAApADsACgB9AAoARQBsAAAXwBtAGEAcwB0AGUAcgBfAG4AbwBlAHQAbABfAHcAaQBuADIAMAAxADIALgB6AGkAcAAiACkACgB7AAoAVwByAGkAdABlAC0ASABvAHMAdAAgACIAMwAiADsACgB9AAoARQBsAHMAZQAKAHsACgBXAHIAaQB0AGUALQBIAG8AcwB0ACAAIgAxACIAOwAKAH0A’]
<52.36.54.12> WINRM RESULT u’<Response code 0, out “22d5bc624a1e6d0ce116”, err “”>’
<52.36.54.12> WINRM STDOUT 22d5bc624a1e6d0ce1162a60ab04f49c70ac3dc8
<52.36.54.12> WINRM STDERR
<52.36.54.12> FETCH “C:\apps\ult_master_noc_win2012.zip” TO “/home/ec2-user/files”
<52.36.54.12> WINRM FETCH “C:\apps\ult_master_noc_win2012.zip” to “/home/ec2-user/files” (offset=0)
<52.36.54.12> WINRM EXEC ‘PowerShell’ [‘-NoProfile’, ‘-NonInteractive’, ‘-ExecutionPolicy’, ‘Unrestricted’, ‘-EncodedCommand’, ‘UwBlAHQALQBTAHQAcgBpAGMAdABNAG8AZABlACAALQBWAGUAcgBzAGkAbwBuACAATABhAHQAZQBzAHQACgBJAGYAIAAoAFQAZQBzAHQALQBQAGEAdABoACAALQBQAGEAdABoAFQAeQBwAGUAIABMAGUAYQBmACAAIgBDADoAXABjAGEAcABzAGUAbgB0AGEAXAB1AGwAdAByAGEAdwByAGEAcABfAG0AYQBzAHQAZQByAFBuADIAMAAxADIALgB6AGkAcAAiACkAOwAKACQAcwB0AHIAZQBhAG0ALgBTAGUAZQBrACgAMAAsACAAWwBTAHkAcwB0AGUAbQAuAEkATwAuAFMAZQBlAGsATwByAGkAZwBpAG4AXQA6ADoAQgBlAGcAaQBuACkAIAB8ACAATwB1AHQALQBOAHUAbABsADsACgAkAGIAdQBmAGYAZQByACAAPQAgAE4AZQB3AC0ATwBiAGoAZQBjAHQAIABCAHkAdABlAFsAXQAgADUAMgA0ADIAOAA4ADsACgAkAGIAeQB0AGUAcwBSAGUAYQBkACAAPQAgACQAcwB0AHIAZQBhAG0ALgBSAGUAYQBkACgAJABiAHUAZgBmAGUAcgAsACAAMAAsACAANQAyADQAMgA4ADgAKQA7AAoAJABiAHkAdABlAHMAIAA9ACAAJABiAHUAZgBmAGUAcgBbADAALgAuACgAJABiAHkAdABlAHMAUgBlAGEAZAAtADEAKQBdADsACgBbAFMAeQBzAHQAZQBtAC4AQwBvAG4AdgBlAHIAdABdADoAOgBUAG8AQgBhAHMAZQA2ADQAUwB0AHIAaQBuAGcAKAAkAGIAeQB0AGUAcwApADsACgAkAHMAdAByAGUAYQBtAC4AMgAuAHoAaQBwACIAKQAKAHsACgBXAHIAaQB0AGUALQBIAG8AcwB0ACAAIgBbAEQASQBSAF0AIgA7AAoAfQAKAEUAbABzAGUACgB7AAoAVwByAGkAdABlAC0ARQByAHIAbwByACAAIgBDADoAXABjAGEAcABzAGUAbgB0AGEAXAB1AGwAdAByAGEAdwByAGEAcABfAG0AYQBzAHQAZQByAF8AbgBvAGUAdABsAF8AdwBpAG4AMgAwADEAMgAuAHoAaQBwACAAZABvAGUAcwAgAG4AbwB0ACAAZQB4AGkAcwB0ACIAOwAKAEUAeABpAHQAIAAxADsACgB9AA==’]
<52.36.54.12> WINRM RESULT u’<Response code 0, out “UEsDBBQAAAAAALsogkgA”, err “”>’
<52.36.54.12> WINRM STDOUT
[Long encoded part deleted]
<52.36.54.12> WINRM STDERR
<52.36.54.12> WINRM CLOSE SHELL: E5D85769-78F7-40DF-9A5F-B98304A49455
changed: [52.36.10.20] => {“changed”: true, “checksum”: null, “dest”: “/home/ec2-user/files”, “invocation”: {“module_args”: {“dest”: “/home/ec2-user/files”, “fail_on_missing”: “yes”, “flat”: “yes”, “src”: “C:\apps\ult_master_noc_win2012.zip”}, “module_name”: “fetch”}, “md5sum”: null, “remote_checksum”: “22d5bc624a1e6d0ce1162a60ab04f49c70ac3dc8”, “remote_md5sum”: null}
TASK [Output the name of the archive] ******************************************
task path: /build_scripts/build_noetl_cust_win.yml:208
ok: [52.36.10.20] => {
"msg": "archive - ult_master_noc_win2012.zip"
}
`