ansible.builtin.win_get_url (v2.8.20) — module

Downloads file from HTTP, HTTPS, or FTP to node

| "added in version" 1.7 of ansible.builtin"

Authors: Paul Durivage (@angstwad), Takeshi Kuramochi (@tksarah)

stableinterface | supported by core

Install Ansible via pip

Install with pip install ansible==2.8.20

Description

Downloads files from HTTP, HTTPS, or FTP to the remote server.

The remote server I(must) have direct access to the remote resource.

For non-Windows targets, use the M(get_url) module instead.

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Download earthrise.jpg to specified path
  win_get_url:
    url: http://www.example.com/earthrise.jpg
    dest: C:\Users\RandomUser\earthrise.jpg
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- 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
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- 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
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- 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
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- 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
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- 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

Inputs

    
url:
    description:
    - The full URL of a file to download.
    required: true
    type: str

dest:
    description:
    - The location to save the file at the URL.
    - Be sure to include a filename and extension as appropriate.
    required: true
    type: path

force:
    default: true
    description:
    - If C(yes), will download the file every time and replace the file if the contents
      change. If C(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.
    type: bool
    version_added: '2.0'
    version_added_collection: ansible.builtin

headers:
    description:
    - Add custom HTTP headers to a request (as a dictionary).
    type: dict
    version_added: '2.4'
    version_added_collection: ansible.builtin

timeout:
    default: 10
    description:
    - Timeout in seconds for URL request.
    type: int
    version_added: '2.4'
    version_added_collection: ansible.builtin

checksum:
    description:
    - If a I(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 I(checksum_url).
    type: str
    version_added: '2.8'
    version_added_collection: ansible.builtin

proxy_url:
    description:
    - The full URL of the proxy server to download through.
    type: str
    version_added: '2.0'
    version_added_collection: ansible.builtin

use_proxy:
    default: true
    description:
    - If C(no), it will not use a proxy, even if one is defined in an environment variable
      on the target hosts.
    type: bool
    version_added: '2.4'
    version_added_collection: ansible.builtin

checksum_url:
    description:
    - Specifies a URL that contains the checksum values for the resource at I(url).
    - Like C(checksum), this is used to verify the integrity of the remote transfer.
    - This option cannot be set with I(checksum).
    type: str
    version_added: '2.8'
    version_added_collection: ansible.builtin

url_password:
    aliases:
    - password
    description:
    - Basic authentication password.
    type: str

url_username:
    aliases:
    - username
    description:
    - Basic authentication username.
    type: str

proxy_password:
    description:
    - Proxy authentication password.
    type: str
    version_added: '2.0'
    version_added_collection: ansible.builtin

proxy_username:
    description:
    - Proxy authentication username.
    type: str
    version_added: '2.0'
    version_added_collection: ansible.builtin

validate_certs:
    default: true
    description:
    - If C(no), SSL certificates will not be validated. This should only be used on personally
      controlled sites using self-signed certificates.
    - If C(skip_certificate_validation) was set, it overrides this option.
    type: bool
    version_added: '2.4'
    version_added_collection: ansible.builtin

force_basic_auth:
    default: false
    description:
    - If C(yes), will add a Basic authentication header on the initial request.
    - If C(no), will use Microsoft's WebClient to handle authentication.
    type: bool
    version_added: '2.5'
    version_added_collection: ansible.builtin

checksum_algorithm:
    choices:
    - md5
    - sha1
    - sha256
    - sha384
    - sha512
    default: sha1
    description:
    - Specifies the hashing algorithm used when calculating the checksum of the remote
      and destination file.
    type: str
    version_added: '2.8'
    version_added_collection: ansible.builtin

Outputs

checksum_dest:
  description: <algorithm> checksum of the file after the download
  returned: success and dest has been downloaded
  sample: 6e642bb8dd5c2e027bf21dd923337cbb4214f827
  type: str
checksum_src:
  description: <algorithm> checksum of the remote resource
  returned: force=yes or dest did not exist
  sample: 6e642bb8dd5c2e027bf21dd923337cbb4214f827
  type: str
dest:
  description: destination file/path
  returned: always
  sample: C:\Users\RandomUser\earthrise.jpg
  type: str
elapsed:
  description: The elapsed seconds between the start of poll and the end of the module.
  returned: always
  sample: 2.1406487
  type: float
msg:
  description: Error message, or HTTP status message from web-server
  returned: always
  sample: OK
  type: str
size:
  description: size of the dest file
  returned: success
  sample: 1220
  type: int
status_code:
  description: HTTP status code
  returned: always
  sample: 200
  type: int
url:
  description: requested url
  returned: always
  sample: http://www.example.com/earthrise.jpg
  type: str

See also