Skip to content
This repository has been archived by the owner on Oct 30, 2018. It is now read-only.

Fetch Silently Fails To Fetch File #3375

Closed
slimandslam opened this issue Apr 6, 2016 · 11 comments
Closed

Fetch Silently Fails To Fetch File #3375

slimandslam opened this issue Apr 6, 2016 · 11 comments

Comments

@slimandslam
Copy link
Contributor

ISSUE TYPE
  • Bug Report
COMPONENT NAME

fetch module

ANSIBLE VERSION
ansible 2.0.1.0
  config file =
  configured module search path = Default w/o overrides
CONFIGURATION
OS / ENVIRONMENT

Running from Amazon Linux 2016.03 release
Target is Windows Server 2012 R2 (recent patches applied)

SUMMARY

Fetching an 80mbyte file from Windows Server silently fails. Ansible does not report an error, but the file never arrives. (Fetching the same file from a remote Linux server works fine, btw)

STEPS TO REPRODUCE
    - 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"
EXPECTED RESULTS

I expect the file to be placed on the control machine.

ACTUAL RESULTS

The file never arrives but the results don't indicate a problem (afaict).

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"
}
@nitzmahone nitzmahone added this to the 2.1.0 milestone Apr 21, 2016
@nitzmahone
Copy link
Member

@slimandslam Aha- took me a bit to figure this out. Assuming your dest is a dir, you need a trailing slash on it. Linux fetch will fail explicitly in this case (sans-trailing-slash will tell you it's a dir, with trailing slash will do what you expect). The Windows fetch is failing to error on the sans-trailing-slash case, and just downloading the file to nowhere. The real clue is the null checksum after fetch has completed. I'll keep this open until we fix the underlying issue (erroring like Linux does). Thanks for the report!

@nitzmahone
Copy link
Member

Turns out this issue isn't Windows-specific. Anything but connection=local that uses the fetch action will fail this way (the failure is on the Ansible controller side).

@nitzmahone nitzmahone changed the title Fetch Silently Fails To Fetch File From Windows Server Fetch Silently Fails To Fetch File Apr 21, 2016
@nitzmahone nitzmahone added P2 and removed windows labels Apr 21, 2016
@nitzmahone nitzmahone modified the milestones: stable-2.0, 2.1.0 Apr 21, 2016
@slimandslam
Copy link
Contributor Author

The destination is always a directory according to the fetch documentation.
Is this really a documentation bug?

@nitzmahone
Copy link
Member

It's actually both a docs bug and an implementation bug. When using flat=yes, it can be either a file or a dir, and the behavior can differ based on the connection plugin (but probably shouldn't). All I tested seem to work with a trailing slash, but Local throws an error if you give it a dir without a trailing slash, winrm and ssh will fail in the way you've noted.

@jctanner jctanner added windows and removed windows labels May 12, 2016
@ansibot
Copy link

ansibot commented Jul 31, 2016

@ansible, ping. This issue is still waiting on your response.
click here for bot help

@ansibot
Copy link

ansibot commented Sep 7, 2016

@ansible, ping. This issue is still waiting on your response.
click here for bot help

@ansibot
Copy link

ansibot commented Oct 6, 2016

@ansible, ping. This issue is still waiting on your response.
click here for bot help

2 similar comments
@ansibot
Copy link

ansibot commented Oct 22, 2016

@ansible, ping. This issue is still waiting on your response.
click here for bot help

@ansibot
Copy link

ansibot commented Nov 6, 2016

@ansible, ping. This issue is still waiting on your response.
click here for bot help

@ansibot
Copy link

ansibot commented Nov 22, 2016

@ansible, ping. This issue is still waiting on your response.
click here for bot help

@ansibot
Copy link

ansibot commented Dec 9, 2016

This repository has been locked. All new issues and pull requests should be filed in https://github.com/ansible/ansible

Please read through the repomerge page in the dev guide. The guide contains links to tools which automatically move your issue or pull request to the ansible/ansible repo.

@ansibot ansibot closed this as completed Sep 11, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants