Closed manpw closed 7 years ago
@blakfeld ping, this issue is waiting for your response. click here for bot help
I'm 99% sure that this has to do with "body" not actually grabbing the file. It looks like with Powershell you'd have to have the 'InFile' flag (at least that's what is noted here: https://www.jfrog.com/knowledge-base/how-do-i-execute-a-file-upload-via-powershell/)
The answer here might be to have a "file" key? I'm not sure what the best user interface is for that.
I'll try and jump on this as soon as I can, but I don't have a lot of access to windows boxes to test this on anymore. If someone wants to take it, the answer is adding the '-InFile' flag to the Invoke-Webrequest bit.
So I think I have some code to fix this, but I've moved to an all Linux shop, so my testing vectors are limited. When I submit a pull request, would you able to see if it fixes your problem?
When you get a chance, can you test this code? It seems to work for me, but I'd love confirmation before I merge it.
@blakfeld, ping. This issue is still waiting on your response. click here for bot help
@blakfeld, ping. This issue is still waiting on your response. click here for bot help
@blakfeld, ping. This issue is still waiting on your response. click here for bot help
I have a PR ready for this, but for some reason the build is failing.
@blakfeld, ping. This issue is still waiting on your response. click here for bot help
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.
The same issue is happening in Ansible 2.2.1 and specifying the body directly in the task instead of reading from a file:
- name: Set server as TPS Processor
win_uri:
url: "http://{{ groups['tps'][0] }}:8080/WSGeomanager/DirectoryService/registerProcessServer"
method: POST
content_type: 'application/xml'
body: "<ProcessServer>
<id>-1</id>
<name></name>
<displayName>{{ inventory_hostname }}</displayName>
<host>{{ inventory_hostname }}</host>
<port>8080</port>
<processors>1</processors>
<executingProcessors>
<value>0</value>
</executingProcessors>
<control>
<id>-1</id>
<appContext>/WSGeomanager</appContext>
<host>{{ groups['tps'][0] }}</host>
<port>8080</port>
</control>
<priority>1</priority>
</ProcessServer>"
A network trace shows that the payload is empty:
I had a fix for this, but I think it got lost when they merged the repos. I've got some free time this week, let me see what I can cook up. Are you up for testing a PR later on?
Sure, I'll be glad to test it.
@jcgarrido Try this out: https://github.com/blakfeld/ansible/blob/add_body_file_win_uri/lib/ansible/modules/windows/win_uri.ps1
I haven't seen anything compelling as to why it's not at least attempting to POST the xml as a string blob, but when googling around it seems that everyone using XML seems to recommend using a file. I know this may not be ideal, but does this at least get you unblocked?
Really, I think the actual answer is reworking the body
param to accept a dict, as opposed to just some string. Then I believe Invoke-Webrequest
will just figure out how to properly format the data.
The problem is I'm generally a Linux admin, and I don't currently have access to the Windows fleet I wrote this module for, so if you have suggestions on improving it, I'll happily accept a PR.
@blakfeld It turned out that I was using quite and old version of the module bundled with Ansible 2.2.0:
I have found that in that version $body is set but never used.
More recent versions of the file already include a fix for that, it was fixed here: https://github.com/ansible/ansible-modules-extras/pull/2504
Thanks a lot for your support.
Since the issue appears to have been fixed in #2504, which would have been released in ansible 2.3.0, I am going to close this. If there are still related issues with this, please open a new issue (in https://github.com/ansible/ansible as ansible-modules-extra is no longer being used for issue tracking or pull requests.
hi,
I am using win_uri to put an archive under artifactory.
ISSUE TYPE
COMPONENT NAME
win_uri
ANSIBLE VERSION
ansible 2.1.0.0 (detached HEAD b599477242) last updated 2016/09/20 16:05:45 (GMT +200) lib/ansible/modules/core: (detached HEAD 04a871d007) last updated 2016/09/20 16:05:48 (GMT +200) lib/ansible/modules/extras: (detached HEAD b5fa2b3416) last updated 2016/09/20 16:05:50 (GMT +200)
name: PUT Generated BI Archive To Artifactory win_uri: url: '{{ test_url}}/{{ version}}/{{ artifactId}}.zip' method: PUT body: "{ '{{ deployDir }}Test_Export_UL.zip': 'application/zip' }" content_type: "application/zip" headers: Authorization: Basic {{ bi_user_pwd | b64encode }} register: stat_repo_upload