win_get_url – Downloads file from HTTP, HTTPS, or FTP to node
win_get_url – Downloads file from HTTP, HTTPS, or FTP to node
Synopsis
- Downloads files from HTTP, HTTPS, or FTP to the remote server.
- The remote server must have direct access to the remote resource.
- For non-Windows targets, use the get_url module instead.
Parameters
Parameter | Choices/Defaults | Comments |
---|---|---|
checksum string added in 2.8 |
If a checksum is passed to this parameter, the digest of the destination file will be calculated after it is downloaded to ensure its integrity and verify that the transfer completed successfully. This option cannot be set with checksum_url. | |
checksum_algorithm string added in 2.8 |
|
Specifies the hashing algorithm used when calculating the checksum of the remote and destination file. |
checksum_url string added in 2.8 |
Specifies a URL that contains the checksum values for the resource at url. Like This option cannot be set with checksum. | |
client_cert string added in 2.9 |
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. | |
client_cert_password string added in 2.9 |
The password for client_cert if the cert is password protected. | |
dest path / required |
The location to save the file at the URL. Be sure to include a filename and extension as appropriate. | |
follow_redirects string added in 2.9 |
|
Whether or the module should follow redirects.
|
force boolean |
|
If This works by sending an http HEAD request to retrieve last modified time of the requested resource, so for this to work, the remote web server must support HEAD requests. |
force_basic_auth boolean added in 2.5 |
|
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. |
headers dictionary added in 2.4 |
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. | |
http_agent string added in 2.9 |
Default: "ansible-httpget" |
Header to identify as, generally appears in web server logs. This is set to the |
maximum_redirection integer added in 2.9 |
Default: 50 |
Specify how many times the module will redirect a connection to an alternative URI before the connection fails. If set to |
method string added in 2.9 |
This option is not for use with | |
proxy_password string |
The password for proxy_username. | |
proxy_url string |
An explicit proxy to use for the request. By default, the request will use the IE defined proxy unless use_proxy is set to | |
proxy_use_default_credential boolean added in 2.9 |
|
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 |
proxy_username string |
The username to use for proxy authentication. | |
timeout integer added in 2.4 |
Default: 30 |
Specifies how long the request can be pending before it times out (in seconds). Set to |
url string / required |
The full URL of a file to download. | |
url_password string |
The password for url_username.
| |
url_username string |
The username to use for authentication.
| |
use_default_credential boolean added in 2.9 |
|
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 |
use_proxy boolean added in 2.4 |
|
If |
validate_certs boolean added in 2.4 |
|
If This should only be used on personally controlled sites using self-signed certificates. |
Notes
Note
- If your URL includes an escaped slash character (%2F) this module will convert it to a real slash. This is a result of the behaviour of the System.Uri class as described in the documentation.
- Since Ansible 2.8, the module will skip reporting a change if the remote checksum is the same as the local local even when
force=yes
. This is to better align with get_url.
See Also
See also
- get_url – Downloads files from HTTP, HTTPS, or FTP to node
- The official documentation on the get_url module.
- uri – Interacts with webservices
- The official documentation on the uri module.
- win_uri – Interacts with webservices
- The official documentation on the win_uri module.
- win_inet_proxy – Manages proxy settings for WinINet and Internet Explorer
- The official documentation on the win_inet_proxy module.
Examples
- name: Download earthrise.jpg to specified path
win_get_url:
url: http://www.example.com/earthrise.jpg
dest: C:\Users\RandomUser\earthrise.jpg
- name: Download earthrise.jpg to specified path only if modified
win_get_url:
url: http://www.example.com/earthrise.jpg
dest: C:\Users\RandomUser\earthrise.jpg
force: no
- name: Download earthrise.jpg to specified path through a proxy server.
win_get_url:
url: http://www.example.com/earthrise.jpg
dest: C:\Users\RandomUser\earthrise.jpg
proxy_url: http://10.0.0.1:8080
proxy_username: username
proxy_password: password
- name: Download file from FTP with authentication
win_get_url:
url: ftp://server/file.txt
dest: '%TEMP%\ftp-file.txt'
url_username: ftp-user
url_password: ftp-password
- name: Download src with sha256 checksum url
win_get_url:
url: http://www.example.com/earthrise.jpg
dest: C:\temp\earthrise.jpg
checksum_url: http://www.example.com/sha256sum.txt
checksum_algorithm: sha256
force: True
- name: Download src with sha256 checksum url
win_get_url:
url: http://www.example.com/earthrise.jpg
dest: C:\temp\earthrise.jpg
checksum: a97e6837f60cec6da4491bab387296bbcd72bdba
checksum_algorithm: sha1
force: True
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key | Returned | Description |
---|---|---|
checksum_dest string |
success and dest has been downloaded |
checksum of the file after the download
Sample: 6e642bb8dd5c2e027bf21dd923337cbb4214f827 |
checksum_src string |
force=yes or dest did not exist |
checksum of the remote resource
Sample: 6e642bb8dd5c2e027bf21dd923337cbb4214f827 |
dest string |
always |
destination file/path
Sample: C:\Users\RandomUser\earthrise.jpg |
elapsed float |
always |
The elapsed seconds between the start of poll and the end of the module.
Sample: 2.1406487 |
msg string |
always |
Error message, or HTTP status message from web-server
Sample: OK |
size integer |
success |
size of the dest file
Sample: 1220 |
status_code integer |
always |
HTTP status code
Sample: 200 |
url string |
always |
requested url
Sample: |
Status
- This module is guaranteed to have backward compatible interface changes going forward. [stableinterface]
- This module is maintained by the Ansible Core Team. [core]
Red Hat Support
More information about Red Hat’s support of this module is available from this Red Hat Knowledge Base article.
Authors
- Paul Durivage (@angstwad)
- Takeshi Kuramochi (@tksarah)
© 2012–2018 Michael DeHaan
© 2018–2019 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/2.9/modules/win_get_url_module.html