2014-09-26 01:01:01 +00:00
|
|
|
#!/usr/bin/python
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
2018-02-25 02:09:54 +00:00
|
|
|
# Copyright: (c) 2014, Paul Durivage <paul.durivage@rackspace.com>, and others
|
|
|
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
2014-09-26 01:01:01 +00:00
|
|
|
|
2018-09-24 15:18:06 +00:00
|
|
|
# This is a windows documentation stub. actual code lives in the .ps1
|
2014-09-26 01:01:01 +00:00
|
|
|
# file of the same name
|
|
|
|
|
2017-08-16 03:16:38 +00:00
|
|
|
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
2017-03-14 16:07:22 +00:00
|
|
|
'status': ['stableinterface'],
|
|
|
|
'supported_by': 'core'}
|
|
|
|
|
2017-01-19 01:57:33 +00:00
|
|
|
DOCUMENTATION = r'''
|
2014-09-26 01:01:01 +00:00
|
|
|
---
|
|
|
|
module: win_get_url
|
|
|
|
version_added: "1.7"
|
2018-05-03 22:39:37 +00:00
|
|
|
short_description: Downloads file from HTTP, HTTPS, or FTP to node
|
2014-09-26 01:01:01 +00:00
|
|
|
description:
|
2019-01-03 16:50:44 +00:00
|
|
|
- Downloads files from HTTP, HTTPS, or FTP to the remote server.
|
|
|
|
- The remote server I(must) have direct access to the remote resource.
|
2017-08-29 00:11:10 +00:00
|
|
|
- For non-Windows targets, use the M(get_url) module instead.
|
2014-09-26 01:01:01 +00:00
|
|
|
options:
|
|
|
|
url:
|
|
|
|
description:
|
2017-08-29 00:11:10 +00:00
|
|
|
- The full URL of a file to download.
|
2018-09-24 15:18:06 +00:00
|
|
|
type: str
|
2019-01-03 16:50:44 +00:00
|
|
|
required: yes
|
2014-09-26 01:01:01 +00:00
|
|
|
dest:
|
|
|
|
description:
|
2017-08-29 00:11:10 +00:00
|
|
|
- The location to save the file at the URL.
|
|
|
|
- Be sure to include a filename and extension as appropriate.
|
2018-07-17 21:29:05 +00:00
|
|
|
type: path
|
2019-01-03 16:50:44 +00:00
|
|
|
required: yes
|
2015-07-10 20:33:00 +00:00
|
|
|
force:
|
|
|
|
description:
|
2019-03-05 10:37:00 +00:00
|
|
|
- If C(yes), will download the file every time and replace the file if the contents change. If C(no), will only
|
2017-08-29 00:11:10 +00:00
|
|
|
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
|
2019-01-03 16:50:44 +00:00
|
|
|
default: yes
|
2015-07-10 20:33:00 +00:00
|
|
|
version_added: "2.0"
|
2017-08-29 00:11:10 +00:00
|
|
|
headers:
|
2015-06-25 20:52:23 +00:00
|
|
|
description:
|
2017-08-29 00:11:10 +00:00
|
|
|
- Add custom HTTP headers to a request (as a dictionary).
|
2018-07-17 21:29:05 +00:00
|
|
|
type: dict
|
2017-08-29 00:11:10 +00:00
|
|
|
version_added: '2.4'
|
|
|
|
url_username:
|
|
|
|
description:
|
|
|
|
- Basic authentication username.
|
2018-09-24 15:18:06 +00:00
|
|
|
type: str
|
2017-08-29 00:11:10 +00:00
|
|
|
aliases: [ username ]
|
|
|
|
url_password:
|
2015-06-25 20:52:23 +00:00
|
|
|
description:
|
2017-08-29 00:11:10 +00:00
|
|
|
- Basic authentication password.
|
2018-09-24 15:18:06 +00:00
|
|
|
type: str
|
2017-08-29 00:11:10 +00:00
|
|
|
aliases: [ password ]
|
2017-12-18 20:38:44 +00:00
|
|
|
force_basic_auth:
|
|
|
|
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
|
2019-01-03 16:50:44 +00:00
|
|
|
default: no
|
2017-12-18 20:38:44 +00:00
|
|
|
version_added: "2.5"
|
2017-07-05 23:56:43 +00:00
|
|
|
validate_certs:
|
|
|
|
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
|
2019-01-03 16:50:44 +00:00
|
|
|
default: yes
|
2017-07-05 23:56:43 +00:00
|
|
|
version_added: '2.4'
|
2019-03-05 10:37:00 +00:00
|
|
|
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"
|
|
|
|
checksum_algorithm:
|
|
|
|
description:
|
|
|
|
- Specifies the hashing algorithm used when calculating the checksum of
|
|
|
|
the remote and destination file.
|
|
|
|
type: str
|
|
|
|
choices:
|
|
|
|
- md5
|
|
|
|
- sha1
|
|
|
|
- sha256
|
2019-03-11 21:56:51 +00:00
|
|
|
- sha384
|
2019-03-05 10:37:00 +00:00
|
|
|
- sha512
|
|
|
|
default: sha1
|
|
|
|
version_added: "2.8"
|
|
|
|
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"
|
2015-08-28 05:46:08 +00:00
|
|
|
proxy_url:
|
|
|
|
description:
|
2017-08-29 00:11:10 +00:00
|
|
|
- The full URL of the proxy server to download through.
|
2018-09-24 15:18:06 +00:00
|
|
|
type: str
|
2015-08-28 05:46:08 +00:00
|
|
|
version_added: "2.0"
|
|
|
|
proxy_username:
|
|
|
|
description:
|
2017-08-29 00:11:10 +00:00
|
|
|
- Proxy authentication username.
|
2018-09-24 15:18:06 +00:00
|
|
|
type: str
|
2015-08-28 05:46:08 +00:00
|
|
|
version_added: "2.0"
|
|
|
|
proxy_password:
|
|
|
|
description:
|
2017-08-29 00:11:10 +00:00
|
|
|
- Proxy authentication password.
|
2018-09-24 15:18:06 +00:00
|
|
|
type: str
|
2015-08-28 05:46:08 +00:00
|
|
|
version_added: "2.0"
|
2017-08-29 00:11:10 +00:00
|
|
|
use_proxy:
|
|
|
|
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
|
2019-01-03 16:50:44 +00:00
|
|
|
default: yes
|
2017-08-29 00:11:10 +00:00
|
|
|
version_added: '2.4'
|
2017-08-29 22:52:39 +00:00
|
|
|
timeout:
|
|
|
|
description:
|
|
|
|
- Timeout in seconds for URL request.
|
2018-07-17 21:29:05 +00:00
|
|
|
type: int
|
2017-08-29 22:52:39 +00:00
|
|
|
default: 10
|
|
|
|
version_added : '2.4'
|
2018-09-24 15:18:06 +00:00
|
|
|
notes:
|
|
|
|
- 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
|
|
|
|
L(the documentation,https://docs.microsoft.com/en-us/dotnet/framework/configure-apps/file-schema/network/schemesettings-element-uri-settings#remarks).
|
2019-03-05 10:37:00 +00:00
|
|
|
- Since Ansible 2.8, the module will skip reporting a change if the remote
|
|
|
|
checksum is the same as the local local even when C(force=yes). This is to
|
|
|
|
better align with M(get_url).
|
2018-12-15 02:23:59 +00:00
|
|
|
seealso:
|
|
|
|
- module: get_url
|
|
|
|
- module: uri
|
|
|
|
- module: win_uri
|
|
|
|
author:
|
|
|
|
- Paul Durivage (@angstwad)
|
|
|
|
- Takeshi Kuramochi (@tksarah)
|
2014-09-26 01:01:01 +00:00
|
|
|
'''
|
|
|
|
|
2016-05-19 22:34:59 +00:00
|
|
|
EXAMPLES = r'''
|
2017-01-19 01:57:33 +00:00
|
|
|
- name: Download earthrise.jpg to specified path
|
2014-09-26 01:01:01 +00:00
|
|
|
win_get_url:
|
2016-11-22 16:07:21 +00:00
|
|
|
url: http://www.example.com/earthrise.jpg
|
|
|
|
dest: C:\Users\RandomUser\earthrise.jpg
|
2015-07-10 20:33:00 +00:00
|
|
|
|
2016-12-15 22:59:07 +00:00
|
|
|
- name: Download earthrise.jpg to specified path only if modified
|
2015-07-10 20:33:00 +00:00
|
|
|
win_get_url:
|
2016-11-22 16:07:21 +00:00
|
|
|
url: http://www.example.com/earthrise.jpg
|
|
|
|
dest: C:\Users\RandomUser\earthrise.jpg
|
2015-07-10 20:33:00 +00:00
|
|
|
force: no
|
2015-08-28 05:46:08 +00:00
|
|
|
|
2016-12-15 22:59:07 +00:00
|
|
|
- name: Download earthrise.jpg to specified path through a proxy server.
|
2015-08-28 05:46:08 +00:00
|
|
|
win_get_url:
|
2016-11-22 16:07:21 +00:00
|
|
|
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
|
2018-05-03 22:39:37 +00:00
|
|
|
|
|
|
|
- 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
|
2019-03-05 10:37:00 +00:00
|
|
|
|
|
|
|
- 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
|
2014-09-26 01:01:01 +00:00
|
|
|
'''
|
2016-12-15 22:59:07 +00:00
|
|
|
|
|
|
|
RETURN = r'''
|
2017-08-29 00:11:10 +00:00
|
|
|
dest:
|
|
|
|
description: destination file/path
|
|
|
|
returned: always
|
2018-12-18 21:25:30 +00:00
|
|
|
type: str
|
2017-08-29 00:11:10 +00:00
|
|
|
sample: C:\Users\RandomUser\earthrise.jpg
|
2019-03-05 10:37:00 +00:00
|
|
|
checksum_dest:
|
|
|
|
description: <algorithm> checksum of the file after the download
|
|
|
|
returned: success and dest has been downloaded
|
|
|
|
type: str
|
|
|
|
sample: 6e642bb8dd5c2e027bf21dd923337cbb4214f827
|
|
|
|
checksum_src:
|
|
|
|
description: <algorithm> checksum of the remote resource
|
|
|
|
returned: force=yes or dest did not exist
|
|
|
|
type: str
|
|
|
|
sample: 6e642bb8dd5c2e027bf21dd923337cbb4214f827
|
2018-08-31 20:20:56 +00:00
|
|
|
elapsed:
|
|
|
|
description: The elapsed seconds between the start of poll and the end of the module.
|
|
|
|
returned: always
|
|
|
|
type: float
|
|
|
|
sample: 2.1406487
|
2019-03-05 10:37:00 +00:00
|
|
|
size:
|
|
|
|
description: size of the dest file
|
|
|
|
returned: success
|
|
|
|
type: int
|
|
|
|
sample: 1220
|
2016-05-27 17:53:35 +00:00
|
|
|
url:
|
|
|
|
description: requested url
|
|
|
|
returned: always
|
2018-12-18 21:25:30 +00:00
|
|
|
type: str
|
2016-12-02 15:39:29 +00:00
|
|
|
sample: http://www.example.com/earthrise.jpg
|
2017-08-29 00:11:10 +00:00
|
|
|
msg:
|
|
|
|
description: Error message, or HTTP status message from web-server
|
2016-05-27 17:53:35 +00:00
|
|
|
returned: always
|
2018-12-18 21:25:30 +00:00
|
|
|
type: str
|
2017-08-29 00:11:10 +00:00
|
|
|
sample: OK
|
|
|
|
status_code:
|
|
|
|
description: HTTP status code
|
|
|
|
returned: always
|
|
|
|
type: int
|
|
|
|
sample: 200
|
2016-05-27 17:53:35 +00:00
|
|
|
'''
|