ansible.builtin.win_get_url (v2.4.2.0-1) — module

Fetches a file from a given URL

| "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.4.2.0.post1

Description

Fetches a file from a URL and saves it locally.

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

Inputs

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

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

force:
    default: 'yes'
    description:
    - If C(yes), will always download the file. 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).
    version_added: '2.4'
    version_added_collection: ansible.builtin

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

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

use_proxy:
    default: 'yes'
    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

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

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

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

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

validate_certs:
    default: 'yes'
    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

skip_certificate_validation:
    default: 'no'
    description:
    - This option is deprecated since v2.4, please use C(validate_certs) instead.
    - If C(yes), SSL certificates will not be validated. This should only be used on personally
      controlled sites using self-signed certificates.
    type: bool

Outputs

dest:
  description: destination file/path
  returned: always
  sample: C:\Users\RandomUser\earthrise.jpg
  type: string
msg:
  description: Error message, or HTTP status message from web-server
  returned: always
  sample: OK
  type: string
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: string