Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to pass in the "dest:" parameter into the "win_uri" module (unlike the "uri" module) #19575

Closed
Michael-B-G opened this issue Dec 20, 2016 · 12 comments
Labels
affects_2.1 This issue/PR affects Ansible v2.1 feature This issue/PR relates to a feature request. module This issue/PR relates to a module. windows Windows community

Comments

@Michael-B-G
Copy link

Michael-B-G commented Dec 20, 2016

ISSUE TYPE
  • Feature Idea
COMPONENT NAME

win_uri module

ANSIBLE VERSION

ansible 2.1.0.0

CONFIGURATION
OS / ENVIRONMENT

N/A

SUMMARY

The "win_uri" module is, in theory, the Windows equivalent of the standard "uri" module (which is normally run on a Linux node). However, in practice, there are certain limitations that the "win_uri" module has versus the "uri" module. For me, the most striking difference is the lack of a "dest" parameter. This is something that we need, as we may use the "win_uri" module to download files from a URL, and we will need the option to store this file at some configurable destination on the server. While the "win_get_url" module DOES allow for a "dest" parameter, it is also limited by not having a "headers" parameter (which I have logged as the separate issue 19573: #19573)

STEPS TO REPRODUCE

Compare the acceptable options here:
http://docs.ansible.com/ansible/uri_module.html

versus here:

http://docs.ansible.com/ansible/win_uri_module.html

win_uri:
url: <URL_TO_FILE_TO_DOWNLOAD>
headers:
<API_TOKEN>: <API_TOKEN_VALUE>
dest: D:\temp\

EXPECTED RESULTS

The file is downloaded in the specified directory. No errors are returned.

ACTUAL RESULTS

There's no error at all, for that matter, and the output makes it appear that the module worked properly. However, no file is downloaded to the specified directory.

ok: [<server_name>] => {"base_response": {"CharacterSet": "UTF-8", "ContentEncoding": "", "ContentLength": 22, "ContentType": "text/plain; charset=UTF-8", "Cookies": [{"Comment": "", "CommentUri": null, "Discard": false, "Domain": "<SERVER_NAME>", "Expired": false, "Expires": "/Date(-62135578800000)/", "HttpOnly": false, "Name": "ROUTEID", "Path": "//", "Port": "", "Secure": false, "TimeStamp": "/Date(1482257645188)/", "Value": ".", "Version": 0}], "Headers": ["X--Id", "X--Node-Id", "X-Checksum-Sha1", "X-Checksum-Md5", "X--Filename", "Content-Disposition", "Connection",
"Accept-Ranges", "Content-Length", "Content-Type", "Date", "ETag", "Last-Modified", "Set-Cookie", "Server"], "IsFromCache": false, "IsMutuallyAuthenticated": false, "LastModified": "/Date(1456626053000)/", "Method": "GET", "ProtocolVersion": {"Build": -1, "Major": 1, "MajorRevision": -1, "Minor": 1, "MinorRevision": -1, "Revision": -1}, "ResponseUri": "<path_to_file>/sample.txt", "Server": "/4.5.1", "StatusCode": 200, "StatusDescription": "OK", "SupportsHeaders": true}, "changed": false, "content": "This is a sample file\n", "headers": {"Accept-Ranges": "bytes", "Connection": "close", "Content-Disposition": "attachment; filename="sample.txt"; filename*=UTF-8''sample.txt", "Content-Length": "22", "Content-Type": "text/plain; charset=UTF-8", "Date": "Tue, 20 Dec 2016 18:14:05 GMT", "ETag": "aad47f5e6428ad31fcadccde1ae203ddc1b45351", "Last-Modified": "Sun, 28 Feb 2016 02:20:53 GMT", "Server": "/4.5.1", "Set-Cookie": "ROUTEID=.; path=//", "X--Filename": "sample.txt", "X--Id": "", "X--Node-Id": "<NODE_ID>", "X-Checksum-Md5": "c80b7d4d21295e061698eb4dac1522df", "X-Checksum-Sha1": "aad47f5e6428ad31fcadccde1ae203ddc1b45351"}, "images": [], "input_fields": [], "invocation": {"module_name": "win_uri"}, "links": [], "raw_content": "HTTP/1.1 200 OK\r\nX--Id: \r\nX--Node-Id: <NODE_ID>2\r\nX-Checksum-Sha1: aad47f5e6428ad31fcadccde1ae203ddc1b45351\r\nX-Checksum-Md5: c80b7d4d21295e061698eb4dac1522df\r\nX--Filename: sample.txt\r\nContent-Disposition: attachment; filename="sample.txt"; filename*=UTF-8''sample.txt\r\nConnection: close\r\nAccept-Ranges: bytes\r\nContent-Length: 22\r\nContent-Type: text/plain; charset=UTF-8\r\nDate: Tue, 20 Dec 2016 18:14:05 GMT\r\nETag: aad47f5e6428ad31fcadccde1ae203ddc1b45351\r\nLast-Modified: Sun, 28 Feb 2016 02:20:53 GMT\r\nSet-Cookie: ROUTEID=.<ROUTE_ID>; path=//\r\nServer: /4.5.1\r\n\r\nThis is a sample file\n", "raw_content_length": 22, "raw_content_stream": {"CanRead": true, "CanSeek": true, "CanTimeout": false, "CanWrite": true, "Capacity": 22, "Length": 22, "Position": 22, "ReadTimeout": null, "WriteTimeout": null}, "status_code": 200, "status_description": "OK", "win_uri": {"content_type": null, "method": "GET", "url": <SERVER_NAME>/sample.txt", "use_basic_parsing": true}}

@ansibot
Copy link
Contributor

ansibot commented Dec 20, 2016

@ansibot ansibot added affects_2.1 This issue/PR affects Ansible v2.1 feature_idea module This issue/PR relates to a module. needs_triage Needs a first human triage before being processed. windows Windows community labels Dec 20, 2016
@blakfeld
Copy link
Contributor

That certainly seems like something it should do! I'm surprised by my oversight.

I'll try to put together a PR before I go AWOL for the holidays, but if I don't, I have some time off next week and will try to see about adding it.

@Michael-B-G
Copy link
Author

Thank you very much, Corwin!

@Michael-B-G
Copy link
Author

Also, this is a minor thing, but is there any way that the source code of win_uri.ps1 and win_uri.py can be made public like the other Windows modules, on this page?

https://github.com/ansible/ansible-modules-core/tree/devel/windows

It's not critical or anything, but I was just curious to see that this module wasn't listed there.

@blakfeld
Copy link
Contributor

It's not listed for 2 reasons:

  1. It was actually a part of "ansible-modules-extras" not core. Almost nothing not written by core devs gets into Core.
  2. They actually merged both of those submodules into Ansible proper! So if you take a look at:
    https://github.com/ansible/ansible/tree/devel/lib/ansible/modules/windows
    You'll see it there!

@Michael-B-G
Copy link
Author

Ah OK, thanks for the clarification!

@blakfeld
Copy link
Contributor

When you get a chance, check out #19577 and see if that works for you.

@Michael-B-G
Copy link
Author

Thank you so much! We will test this out ASAP!

@Michael-B-G
Copy link
Author

Michael-B-G commented Dec 20, 2016

Hi Corwin,

Thank you again for working on this promptly. I sincerely appreciate it. I just tested out this enhancement, but unfortunately, I get the following result:

An exception occurred during task execution. The full traceback is:
At C:\Users<PATH>\ansible-tmp-1482265149.31-53904463291507\win_uri.ps1:302 char:5

+ Set-Attr $result.dest "dest" $dest

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fatal: [rlm-bccwdvapp01.sysdev.adroot.bmogc.net]: FAILED! => {"changed": false, "failed": true, "invocation": {"module_name": "win_uri"}, "msg": "The property 'dest' cannot be found on this object. Verify that the property exists."}

My playbook is exactly as described before. It appears that there may be an issue with the new code checked in; alternatively, if there is anything I need to do on my end, please let me know.

Let me know what you think.

All the best,

Michael

@blakfeld
Copy link
Contributor

Yup, that's totally right, that will bomb out. Sorry about that, try it again now

@Michael-B-G
Copy link
Author

It works! Thank you so much, Corwin!

@abadger abadger removed the needs_triage Needs a first human triage before being processed. label Jan 4, 2017
nitzmahone pushed a commit that referenced this issue Jan 4, 2017
* Issue #19575: Adding Dest Param to win_uri

Added `dest` param to win_uri. Outputs the response body to a specified
file.

Addresses Issue #19575

* Was setting the wrong attribute
@jimi-c jimi-c removed the plugin label Jan 4, 2017
@abadger
Copy link
Contributor

abadger commented Jan 4, 2017

#19577 has been merged. Closing this as fixed.

@abadger abadger closed this as completed Jan 4, 2017
@ansibot ansibot added feature This issue/PR relates to a feature request. and removed feature_idea labels Mar 2, 2018
@ansible ansible locked and limited conversation to collaborators Apr 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.1 This issue/PR affects Ansible v2.1 feature This issue/PR relates to a feature request. module This issue/PR relates to a module. windows Windows community
Projects
None yet
Development

No branches or pull requests

5 participants