Debian Codegraph @

test/support/windows-integration/plugins/modules/win_get_url.py

raw
1 #!/usr/bin/python
2 # -*- coding: utf-8 -*-
3
4 # Copyright: (c) 2014, Paul Durivage <[email protected]>, and others
5 # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
6
7 # This is a windows documentation stub. actual code lives in the .ps1
8 # file of the same name
9
10 ANSIBLE_METADATA = {'metadata_version': '1.1',
11 'status': ['stableinterface'],
12 'supported_by': 'core'}
13
14 DOCUMENTATION = r"""
15 ---
16 module: win_get_url
17 version_added: "1.7"
18 short_description: Downloads file from HTTP, HTTPS, or FTP to node
19 description:
20 - Downloads files from HTTP, HTTPS, or FTP to the remote server.
21 - The remote server I(must) have direct access to the remote resource.
22 - For non-Windows targets, use the M(get_url) module instead.
23 options:
24 url:
25 description:
26 - The full URL of a file to download.
27 type: str
28 required: yes
29 dest:
30 description:
31 - The location to save the file at the URL.
32 - Be sure to include a filename and extension as appropriate.
33 type: path
34 required: yes
35 force:
36 description:
37 - If C(yes), will download the file every time and replace the file if the contents change. If C(no), will only
38 download the file if it does not exist or the remote file has been
39 modified more recently than the local file.
40 - This works by sending an http HEAD request to retrieve last modified
41 time of the requested resource, so for this to work, the remote web
42 server must support HEAD requests.
43 type: bool
44 default: yes
45 version_added: "2.0"
46 checksum:
47 description:
48 - If a I(checksum) is passed to this parameter, the digest of the
49 destination file will be calculated after it is downloaded to ensure
50 its integrity and verify that the transfer completed successfully.
51 - This option cannot be set with I(checksum_url).
52 type: str
53 version_added: "2.8"
54 checksum_algorithm:
55 description:
56 - Specifies the hashing algorithm used when calculating the checksum of
57 the remote and destination file.
58 type: str
59 choices:
60 - md5
61 - sha1
62 - sha256
63 - sha384
64 - sha512
65 default: sha1
66 version_added: "2.8"
67 checksum_url:
68 description:
69 - Specifies a URL that contains the checksum values for the resource at
70 I(url).
71 - Like C(checksum), this is used to verify the integrity of the remote
72 transfer.
73 - This option cannot be set with I(checksum).
74 type: str
75 version_added: "2.8"
76 url_username:
77 description:
78 - The username to use for authentication.
79 - The aliases I(user) and I(username) are deprecated and will be removed in
80 Ansible 2.14.
81 aliases:
82 - user
83 - username
84 url_password:
85 description:
86 - The password for I(url_username).
87 - The alias I(password) is deprecated and will be removed in Ansible 2.14.
88 aliases:
89 - password
90 proxy_url:
91 version_added: "2.0"
92 proxy_username:
93 version_added: "2.0"
94 proxy_password:
95 version_added: "2.0"
96 headers:
97 version_added: "2.4"
98 use_proxy:
99 version_added: "2.4"
100 follow_redirects:
101 version_added: "2.9"
102 maximum_redirection:
103 version_added: "2.9"
104 client_cert:
105 version_added: "2.9"
106 client_cert_password:
107 version_added: "2.9"
108 method:
109 description:
110 - This option is not for use with C(win_get_url) and should be ignored.
111 version_added: "2.9"
112 notes:
113 - If your URL includes an escaped slash character (%2F) this module will convert it to a real slash.
114 This is a result of the behaviour of the System.Uri class as described in
115 L(the documentation,https://docs.microsoft.com/en-us/dotnet/framework/configure-apps/file-schema/network/schemesettings-element-uri-settings#remarks).
116 - Since Ansible 2.8, the module will skip reporting a change if the remote
117 checksum is the same as the local local even when C(force=yes). This is to
118 better align with M(get_url).
119 extends_documentation_fragment:
120 - url_windows
121 seealso:
122 - module: get_url
123 - module: uri
124 - module: win_uri
125 author:
126 - Paul Durivage (@angstwad)
127 - Takeshi Kuramochi (@tksarah)
128 """
129
130 EXAMPLES = r"""
131 - name: Download earthrise.jpg to specified path
132 win_get_url:
133 url: http://www.example.com/earthrise.jpg
134 dest: C:\Users\RandomUser\earthrise.jpg
135
136 - name: Download earthrise.jpg to specified path only if modified
137 win_get_url:
138 url: http://www.example.com/earthrise.jpg
139 dest: C:\Users\RandomUser\earthrise.jpg
140 force: no
141
142 - name: Download earthrise.jpg to specified path through a proxy server.
143 win_get_url:
144 url: http://www.example.com/earthrise.jpg
145 dest: C:\Users\RandomUser\earthrise.jpg
146 proxy_url: http://10.0.0.1:8080
147 proxy_username: username
148 proxy_password: password
149
150 - name: Download file from FTP with authentication
151 win_get_url:
152 url: ftp://server/file.txt
153 dest: '%TEMP%\ftp-file.txt'
154 url_username: ftp-user
155 url_password: ftp-password
156
157 - name: Download src with sha256 checksum url
158 win_get_url:
159 url: http://www.example.com/earthrise.jpg
160 dest: C:\temp\earthrise.jpg
161 checksum_url: http://www.example.com/sha256sum.txt
162 checksum_algorithm: sha256
163 force: True
164
165 - name: Download src with sha256 checksum url
166 win_get_url:
167 url: http://www.example.com/earthrise.jpg
168 dest: C:\temp\earthrise.jpg
169 checksum: a97e6837f60cec6da4491bab387296bbcd72bdba
170 checksum_algorithm: sha1
171 force: True
172 """
173
174 RETURN = r"""
175 dest:
176 description: destination file/path
177 returned: always
178 type: str
179 sample: C:\Users\RandomUser\earthrise.jpg
180 checksum_dest:
181 description: <algorithm> checksum of the file after the download
182 returned: success and dest has been downloaded
183 type: str
184 sample: 6e642bb8dd5c2e027bf21dd923337cbb4214f827
185 checksum_src:
186 description: <algorithm> checksum of the remote resource
187 returned: force=yes or dest did not exist
188 type: str
189 sample: 6e642bb8dd5c2e027bf21dd923337cbb4214f827
190 elapsed:
191 description: The elapsed seconds between the start of poll and the end of the module.
192 returned: always
193 type: float
194 sample: 2.1406487
195 size:
196 description: size of the dest file
197 returned: success
198 type: int
199 sample: 1220
200 url:
201 description: requested url
202 returned: always
203 type: str
204 sample: http://www.example.com/earthrise.jpg
205 msg:
206 description: Error message, or HTTP status message from web-server
207 returned: always
208 type: str
209 sample: OK
210 status_code:
211 description: HTTP status code
212 returned: always
213 type: int
214 sample: 200
215 """