ansible.windows.win_get_url module – Downloads file from HTTP, HTTPS, or FTP to node
Note
This module is part of the ansible.windows collection (version 2.5.0).
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_get_url
.
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 ansible.builtin.get_url module instead.
Parameters
Parameter |
Comments |
---|---|
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. |
|
Specifies the hashing algorithm used when calculating the checksum of the remote and destination file. Choices:
|
|
Specifies a URL that contains the checksum values for the resource at url. Like This option cannot be set with checksum. |
|
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. |
|
The location to save the file at the URL. Be sure to include a filename and extension as appropriate. |
|
Whether or the module should follow redirects.
When following a redirected URL, the Choices:
|
|
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. 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. |
|
The full URL of a file to download. |
|
The HTTP Method of the request. |
|
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:
|
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.
See Also
See also
- ansible.builtin.get_url
The official documentation on the ansible.builtin.get_url module.
- ansible.builtin.uri
The official documentation on the ansible.builtin.uri module.
- ansible.windows.win_uri
Interacts with webservices.
- community.windows.win_inet_proxy
The official documentation on the community.windows.win_inet_proxy module.
Examples
- name: Download earthrise.jpg to specified path
ansible.windows.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
ansible.windows.win_get_url:
url: http://www.example.com/earthrise.jpg
dest: C:\Users\RandomUser\earthrise.jpg
force: false
- name: Download earthrise.jpg to specified path through a proxy server.
ansible.windows.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
ansible.windows.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
ansible.windows.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
ansible.windows.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 |
Description |
---|---|
<algorithm> checksum of the file after the download Returned: success and dest has been downloaded Sample: |
|
<algorithm> checksum of the remote resource Returned: force=true or dest did not exist Sample: |
|
destination file/path Returned: always Sample: |
|
The elapsed seconds between the start of poll and the end of the module. Returned: always Sample: |
|
Error message, or HTTP status message from web-server Returned: always Sample: |
|
size of the dest file Returned: success Sample: |
|
HTTP status code Returned: always Sample: |
|
requested url Returned: always Sample: |