ansible.windows.win_uri module – Interacts with webservices
Note
This module is part of the ansible.windows collection (version 2.5.0).
You might already have this collection installed if you are using the ansible
package.
It is not included in ansible-core
.
To check whether it is installed, run ansible-galaxy collection list
.
To install it, use: ansible-galaxy collection install ansible.windows
.
To use it in a playbook, specify: ansible.windows.win_uri
.
Synopsis
Interacts with FTP, HTTP and HTTPS web services.
Supports Digest, Basic and WSSE HTTP authentication mechanisms.
For non-Windows targets, use the ansible.builtin.uri module instead.
Parameters
Parameter |
Comments |
---|---|
The body of the HTTP request/response to the web service. |
|
The path to the client certificate (.pfx) that is used for X509 authentication. This path can either be the path to the The WinRM connection must be authenticated with Other authentication types can set client_cert_password when the cert is password protected. |
|
The password for client_cert if the cert is password protected. |
|
Sets the “Content-Type” header. |
|
A filename, when it already exists, this step will be skipped. |
|
Output the response body to a file. |
|
Whether or the module should follow redirects.
When following a redirected URL, the Choices:
|
|
By default the authentication header is only sent when a webservice responses to an initial request with a 401 status. Since some basic auth services do not properly send a 401, logins will fail. This option forces the sending of the Basic authentication header upon the original request. Choices:
|
|
Extra headers to set on the request. This should be a dictionary where the key is the header name and the value is the value for that header. |
|
Header to identify as, generally appears in web server logs. This is set to the Default: |
|
Specify how many times the module will redirect a connection to an alternative URI before the connection fails. If set to Default: |
|
The password for proxy_username. |
|
An explicit proxy to use for the request. By default, the request will use the IE defined proxy unless use_proxy is set to |
|
Uses the current user’s credentials when authenticating with a proxy host protected with Proxies that use The module will only have access to the user’s credentials if using If not using Choices:
|
|
The username to use for proxy authentication. |
|
A filename, when it does not exist, this step will be skipped. |
|
Whether or not to return the body of the response as a “content” key in the dictionary result. If the reported Content-type is “application/json”, then the JSON is additionally loaded into a key called Choices:
|
|
A valid, numeric, HTTP status code that signifies success of the request. Can also be comma separated list of status codes. Default: |
|
Supports FTP, HTTP or HTTPS URLs in the form of (ftp|http|https)://host.domain:port/path. |
|
The HTTP Method of the request. Default: |
|
The password for url_username. |
|
Specifies how long the request can be pending before it times out (in seconds). Set to Default: |
|
The username to use for authentication. |
|
Uses the current user’s credentials when authenticating with a server protected with Sites that use The module will only have access to the user’s credentials if using If not using Choices:
|
|
If Choices:
|
|
If This should only be used on personally controlled sites using self-signed certificates. Choices:
|
See Also
See also
- ansible.builtin.uri
Interacts with webservices.
- ansible.windows.win_get_url
Downloads file from HTTP, HTTPS, or FTP to node.
- community.windows.win_inet_proxy
Manages proxy settings for WinINet and Internet Explorer.
Examples
- name: Perform a GET and Store Output
ansible.windows.win_uri:
url: http://example.com/endpoint
register: http_output
# Set a HOST header to hit an internal webserver:
- name: Hit a Specific Host on the Server
ansible.windows.win_uri:
url: http://example.com/
method: GET
headers:
host: www.somesite.com
- name: Perform a HEAD on an Endpoint
ansible.windows.win_uri:
url: http://www.example.com/
method: HEAD
- name: POST a Body to an Endpoint
ansible.windows.win_uri:
url: http://www.somesite.com/
method: POST
body: "{ 'some': 'json' }"
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
---|---|
The raw content of the HTTP response. Returned: success and return_content is True Sample: |
|
The byte size of the response. Returned: success Sample: |
|
The number of seconds that elapsed while performing the download. Returned: always Sample: |
|
The json structure returned under content as a dictionary. Returned: success and Content-Type is “application/json” or “application/javascript” and return_content is True Sample: |
|
The HTTP Status Code of the response. Returned: success Sample: |
|
A summary of the status. Returned: success Sample: |
|
The Target URL. Returned: always Sample: |