New in version 2.1.
Interacts with HTTP and HTTPS web services and supports Digest, Basic and WSSE HTTP authentication mechanisms.
parameter | required | default | choices | comments |
---|---|---|---|---|
body | no | The body of the HTTP request/response to the web service. |
||
content_type | no | Sets the "Content-Type" header. |
||
headers | no | Key Value pairs for headers. Example "Host: www.somesite.com" |
||
method | no | GET |
| The HTTP Method of the request or response. |
url | no | HTTP or HTTPS URL in the form of (http|https)://host.domain:port/path |
||
use_basic_parsing | no | True |
| This module relies upon 'Invoke-WebRequest', which by default uses the Internet Explorer Engine to parse a webpage. There's an edge-case where if a user hasn't run IE before, this will fail. The only advantage to using the Internet Explorer praser is that you can traverse the DOM in a powershell script. That isn't useful for Ansible, so by default we toggle 'UseBasicParsing'. However, you can toggle that off here. |
# Send a GET request and store the output: --- - name: Perform a GET and Store Output win_uri: url: http://www.somesite.com/myendpoint register: http_output # Set a HOST header to hit an internal webserver: --- - name: Hit a Specific Host on the Server win_uri: url: http://my.internal.server.com method: GET headers: host: "www.somesite.com" # Do a HEAD request on an endpoint --- - name: Perform a HEAD on an Endpoint win_uri: url: http://www.somesite.com method: HEAD # Post a body to an endpoint --- - name: POST a Body to an Endpoint win_uri: url: http://www.somesite.com method: POST body: "{ 'some': 'json' }"
Common return values are documented here Common Return Values, the following are the fields unique to this module:
name | description | returned | type | sample |
---|---|---|---|---|
url | The Target URL | always | string | https://www.ansible.com |
status_code | The HTTP Status Code of the response. | success | int | 200 |
use_basic_parsing | The state of the "use_basic_parsing" flag. | always | bool | True |
raw_content | The raw content of the HTTP response. | success | string | HTTP/1.1 200 OK X-XSS-Protection: 1; mode=block X-Frame-Options: SAMEORIGIN Alternate-Protocol: 443:quic,p=1 Alt-Svc: quic="www.google.com:443"; ma=2592000; v="30,29,28,27,26,25",quic=":443"; ma=2... |
headers | The Headers of the response. | success | dict | {'Content-Type': 'application/json'} |
content_type | The "content-type" header used. | always | string | application/json |
raw_content_length | The byte size of the response. | success | int | 54447 |
status_description | A summery of the status. | success | string | |
method | The HTTP method used. | always | string | GET |
For more information on what this means please read Extras Modules
For help in developing on modules, should you be so inclined, please read Community Information & Contributing, developing_test_pr and Developing Modules.
© 2012–2016 Michael DeHaan
© 2016 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/win_uri_module.html