win_get_url – Downloads file from HTTP, HTTPS, or FTP to node

From Get docs
Ansible/docs/2.8/modules/win get url module


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

  • md5
  • sha1

  • sha256
  • sha384
  • sha512

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 checksum, this is used to verify the integrity of the remote transfer.

This option cannot be set with checksum.

dest

path / required

The location to save the file at the URL.

Be sure to include a filename and extension as appropriate.

force

boolean

added in 2.0

  • no
  • yes

If yes, will download the file every time and replace the file if the contents change. If no, will only download the file if it does not exist or the remote file has been modified more recently than the local file.

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

  • no

  • yes

If yes, will add a Basic authentication header on the initial request.

If no, will use Microsoft's WebClient to handle authentication.

headers

dictionary

added in 2.4

Add custom HTTP headers to a request (as a dictionary).

proxy_password

string

added in 2.0

Proxy authentication password.

proxy_url

string

added in 2.0

The full URL of the proxy server to download through.

proxy_username

string

added in 2.0

Proxy authentication username.

timeout

integer

added in 2.4

Default:

10

Timeout in seconds for URL request.

url

string / required

The full URL of a file to download.

url_password

string

Basic authentication password.


aliases: password

url_username

string

Basic authentication username.


aliases: username

use_proxy

boolean

added in 2.4

  • no
  • yes

If no, it will not use a proxy, even if one is defined in an environment variable on the target hosts.

validate_certs

boolean

added in 2.4

  • no
  • yes

If no, SSL certificates will not be validated. This should only be used on personally controlled sites using self-signed certificates.

If skip_certificate_validation was set, it overrides this option.



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.


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

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)

Hint

If you notice any issues in this documentation you can edit this document to improve it.


© 2012–2018 Michael DeHaan
© 2018–2019 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/2.8/modules/win_get_url_module.html