Anons79 Mini Shell

Directory : /lib/python2.7/site-packages/ansible/modules/net_tools/basics/
Upload File :
Current File : //lib/python2.7/site-packages/ansible/modules/net_tools/basics/get_url.pyc

�
�Udac@`s'ddlmZmZmZeZidd6dgd6dd6ZdZd	Zd
Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZddlmZdd
lmZddlmZddlmZmZd�Zdddd�Zd�Zd�Zedkr#e�ndS(i(tabsolute_importtdivisiontprint_functions1.1tmetadata_versiontstableinterfacetstatustcoretsupported_bys9
---
module: get_url
short_description: Downloads files from HTTP, HTTPS, or FTP to node
description:
     - Downloads files from HTTP, HTTPS, or FTP to the remote server. The remote
       server I(must) have direct access to the remote resource.
     - By default, if an environment variable C(<protocol>_proxy) is set on
       the target host, requests will be sent through that proxy. This
       behaviour can be overridden by setting a variable for this task
       (see `setting the environment
       <https://docs.ansible.com/playbooks_environment.html>`_),
       or by using the use_proxy option.
     - HTTP redirects can redirect from HTTP to HTTPS so you should be sure that
       your proxy environment for both protocols is correct.
     - From Ansible 2.4 when run with C(--check), it will do a HEAD request to validate the URL but
       will not download the entire file or verify it against hashes.
     - For Windows targets, use the M(win_get_url) module instead.
version_added: '0.6'
options:
  url:
    description:
      - HTTP, HTTPS, or FTP URL in the form (http|https|ftp)://[user[:pass]]@host.domain[:port]/path
    type: str
    required: true
  dest:
    description:
      - Absolute path of where to download the file to.
      - If C(dest) is a directory, either the server provided filename or, if
        none provided, the base name of the URL on the remote server will be
        used. If a directory, C(force) has no effect.
      - If C(dest) is a directory, the file will always be downloaded
        (regardless of the C(force) option), but replaced only if the contents changed..
    type: path
    required: true
  tmp_dest:
    description:
      - Absolute path of where temporary file is downloaded to.
      - When run on Ansible 2.5 or greater, path defaults to ansible's remote_tmp setting
      - When run on Ansible prior to 2.5, it defaults to C(TMPDIR), C(TEMP) or C(TMP) env variables or a platform specific value.
      - U(https://docs.python.org/2/library/tempfile.html#tempfile.tempdir)
    type: path
    version_added: '2.1'
  force:
    description:
      - If C(yes) and C(dest) is not a directory, will download the file every
        time and replace the file if the contents change. If C(no), the file
        will only be downloaded if the destination does not exist. Generally
        should be C(yes) only for small local files.
      - Prior to 0.6, this module behaved as if C(yes) was the default.
      - Alias C(thirsty) has been deprecated and will be removed in 2.13.
    type: bool
    default: no
    aliases: [ thirsty ]
    version_added: '0.7'
  backup:
    description:
      - Create a backup file including the timestamp information so you can get
        the original file back if you somehow clobbered it incorrectly.
    type: bool
    default: no
    version_added: '2.1'
  sha256sum:
    description:
      - If a SHA-256 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 is deprecated. Use C(checksum) instead.
    default: ''
    version_added: "1.3"
  checksum:
    description:
      - '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.
        Format: <algorithm>:<checksum|url>, e.g. checksum="sha256:D98291AC[...]B6DC7B97",
        checksum="sha256:http://example.com/path/sha256sum.txt"'
      - If you worry about portability, only the sha1 algorithm is available
        on all platforms and python versions.
      - The third party hashlib library can be installed for access to additional algorithms.
      - Additionally, if a checksum is passed to this parameter, and the file exist under
        the C(dest) location, the I(destination_checksum) would be calculated, and if
        checksum equals I(destination_checksum), the file download would be skipped
        (unless C(force) is true). If the checksum does not equal I(destination_checksum),
        the destination file is deleted.
    type: str
    default: ''
    version_added: "2.0"
  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
    default: yes
  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.
    type: bool
    default: yes
  timeout:
    description:
      - Timeout in seconds for URL request.
    type: int
    default: 10
    version_added: '1.8'
  headers:
    description:
        - Add custom HTTP headers to a request in hash/dict format.
        - The hash/dict format was added in Ansible 2.6.
        - Previous versions used a C("key:value,key:value") string format.
        - The C("key:value,key:value") string format is deprecated and will be removed in version 2.10.
    type: raw
    version_added: '2.0'
  url_username:
    description:
      - The username for use in HTTP basic authentication.
      - This parameter can be used without C(url_password) for sites that allow empty passwords.
      - Since version 2.8 you can also use the C(username) alias for this option.
    type: str
    aliases: ['username']
    version_added: '1.6'
  url_password:
    description:
        - The password for use in HTTP basic authentication.
        - If the C(url_username) parameter is not specified, the C(url_password) parameter will not be used.
        - Since version 2.8 you can also use the 'password' alias for this option.
    type: str
    aliases: ['password']
    version_added: '1.6'
  force_basic_auth:
    description:
      - Force the sending of the Basic authentication header upon initial request.
      - httplib2, the library used by the uri module only sends authentication information when a webservice
        responds to an initial request with a 401 status. Since some basic auth services do not properly
        send a 401, logins will fail.
    type: bool
    default: no
    version_added: '2.0'
  client_cert:
    description:
      - PEM formatted certificate chain file to be used for SSL client authentication.
      - This file can also include the key as well, and if the key is included, C(client_key) is not required.
    type: path
    version_added: '2.4'
  client_key:
    description:
      - PEM formatted file that contains your private key to be used for SSL client authentication.
      - If C(client_cert) contains both the certificate and key, this option is not required.
    type: path
    version_added: '2.4'
  http_agent:
    description:
      - Header to identify as, generally appears in web server logs.
    type: str
    default: ansible-httpget
# informational: requirements for nodes
extends_documentation_fragment:
    - files
notes:
     - For Windows targets, use the M(win_get_url) module instead.
seealso:
- module: uri
- module: win_get_url
author:
- Jan-Piet Mens (@jpmens)
s~
- name: Download foo.conf
  get_url:
    url: http://example.com/path/file.conf
    dest: /etc/foo.conf
    mode: '0440'

- name: Download file and force basic auth
  get_url:
    url: http://example.com/path/file.conf
    dest: /etc/foo.conf
    force_basic_auth: yes

- name: Download file with custom HTTP headers
  get_url:
    url: http://example.com/path/file.conf
    dest: /etc/foo.conf
    headers:
      key1: one
      key2: two

- name: Download file with check (sha256)
  get_url:
    url: http://example.com/path/file.conf
    dest: /etc/foo.conf
    checksum: sha256:b5bb9d8014a0f9b1d61e21e796d78dccdf1352f23cd32812f4850b878ae4944c

- name: Download file with check (md5)
  get_url:
    url: http://example.com/path/file.conf
    dest: /etc/foo.conf
    checksum: md5:66dffb5228a211e61d6d7ef4a86f5758

- name: Download file with checksum url (sha256)
  get_url:
    url: http://example.com/path/file.conf
    dest: /etc/foo.conf
    checksum: sha256:http://example.com/path/sha256sum.txt

- name: Download file from a file path
  get_url:
    url: file:///tmp/afile.txt
    dest: /tmp/afilecopy.txt

- name: < Fetch file that requires authentication.
        username/password only available since 2.8, in older versions you need to use url_username/url_password
  get_url:
    url: http://example.com/path/file.conf
    dest: /etc/foo.conf
    username: bar
    password: '{{ mysecret }}'
s�
backup_file:
    description: name of backup file created after download
    returned: changed and if backup=yes
    type: str
    sample: /path/to/file.txt.2015-02-12@22:09~
checksum_dest:
    description: sha1 checksum of the file after copy
    returned: success
    type: str
    sample: 6e642bb8dd5c2e027bf21dd923337cbb4214f827
checksum_src:
    description: sha1 checksum of the file
    returned: success
    type: str
    sample: 6e642bb8dd5c2e027bf21dd923337cbb4214f827
dest:
    description: destination file/path
    returned: success
    type: str
    sample: /path/to/file.txt
elapsed:
    description: The number of seconds that elapsed while performing the download
    returned: always
    type: int
    sample: 23
gid:
    description: group id of the file
    returned: success
    type: int
    sample: 100
group:
    description: group of the file
    returned: success
    type: str
    sample: "httpd"
md5sum:
    description: md5 checksum of the file after download
    returned: when supported
    type: str
    sample: "2a5aeecc61dc98c4d780b14b330e3282"
mode:
    description: permissions of the target
    returned: success
    type: str
    sample: "0644"
msg:
    description: the HTTP message from the request
    returned: always
    type: str
    sample: OK (unknown bytes)
owner:
    description: owner of the file
    returned: success
    type: str
    sample: httpd
secontext:
    description: the SELinux security context of the file
    returned: success
    type: str
    sample: unconfined_u:object_r:user_tmp_t:s0
size:
    description: size of the target
    returned: success
    type: int
    sample: 1220
src:
    description: source file used after download
    returned: always
    type: str
    sample: /tmp/tmpAdFLdV
state:
    description: state of the target
    returned: success
    type: str
    sample: file
status_code:
    description: the HTTP status code from the request
    returned: always
    type: int
    sample: 200
uid:
    description: owner id of the file, after execution
    returned: success
    type: int
    sample: 100
url:
    description: the actual URL used for the request
    returned: always
    type: str
    sample: https://www.ansible.com/
N(t
AnsibleModule(turlsplit(t	to_native(t	fetch_urlturl_argument_speccC`s0tjjt|�d�}|dkr,dS|S(Nits
index.html(tostpathtbasenameR	(turltfn((sL/usr/lib/python2.7/site-packages/ansible/modules/net_tools/basics/get_url.pyturl_filenameXsi
R
c	C`s�|jrd}	nd}	tjj�}
t||d|d|d|d|d|d|	�\}}tjj�|
j}
|d	d
kr�|jd|d|d
td|jdd�d|
�n|d	dkr�|jd|dd|d|d|
�n|d	dkrz|j	d�rz|j	d�o=|jdd�j	d�rz|jddd|d	d|dd|d|d|
�n|r�t
jj|�}|s�t
jj
|�r�|jdd|d|
�q�|jdd|d|
�q�n	|j}tjd|�\}}t
j|d�}ytj||�WnLtk
r|}t
j|�|jddt|�d|
dtj��nX|j�|j�||fS(sr
    Download data from the url and store in a temporary file.

    Return (tempfile, info about the request)
    tHEADtGETt	use_proxytforcet
last_mod_timettimeouttheaderstmethodRi0RtdesttchangedtmsgR
telapsedi����i�sfile:/sftp:/tOKsRequest failedtstatus_codetresponses'%s is a file but should be a directory.s%s directory does not exist.tdirtwbs+failed to create temporary content file: %st	exception(t
check_modetdatetimetutcnowRtsecondst	exit_jsontFalsetgett	fail_jsont
startswithRRtisdirtexiststtmpdirttempfiletmkstemptfdopentshutiltcopyfileobjt	ExceptiontremoveR
t	tracebackt
format_exctclose(tmoduleRRRRRRRttmp_destRtstarttrsptinfoRttmp_dest_is_dirtfdttempnametfte((sL/usr/lib/python2.7/site-packages/ansible/modules/net_tools/basics/get_url.pyturl_get_s:		97)K9 	
0

cC`sed}d}d|kra|d}tj||�}|ra|jd�}tjj|�}qan|S(s�
    Extracts a filename from the given dict of HTTP headers.

    Looks for the content-disposition header and applies a regex.
    Returns the filename if successful, else None.sattachment; ?filename="?([^"]+)scontent-dispositioniN(tNonetretmatchtgroupRRR(Rtcont_disp_regextrest	cont_dispRI((sL/usr/lib/python2.7/site-packages/ansible/modules/net_tools/basics/get_url.pytextract_filename_from_headers�s
c"`s�
t�}dg|dd<dg|dd<|jdtddd	t�d
tddd	t�dtdd
�dtdddd�dtdddd�dtdddd�dtdd�dtdd��td|dtdtdddgg�}|jjd�r|jddd�n|jd}|jd
}|jd}|jd }|jd}|jd}|jd!}|jd}	|jd}
td"td#dd$dd
|d%d&d|�}t
|jdt�r�|jd}nz|jdrYy=td'�|jdjd(�D��}|jd)dd*�Wq_tk
rU|j
d+d,|�q_Xnd}tjj|�}
d}|r�d-|}n|r�y|jd.d/�\}}Wn$tk
r�|j
d+d0|�nX|jd1�s|jd2�s|jd3�r0|}t|||||||	||
�	\}}t|��)}g|D]}|jd4�^qF}WdQXtj|�i}xG|D]?}|jdd/�}t|�d5kr�|d/||d&<q�q�Wt|��x1�fd6�|j�D�D]
}|}Pq�Wd}|dkr0|j
d+d7�|f�q0ntjd8d|�j�}yt|d9�Wq�tk
r�|j
d+d:|�q�Xn|
r�tjj|�r�t}|r�|dkr�|j||�}||kr�t}q�n|rk|rk|rk||jd<|j |j�}||d<|j!|t�|d"<|d"rU|j"d+d;|�n|j"d+d<|�ntjj#|�}t$j$j%|�}|r�t}q�nt$j$j&�}t|||||||	||
�	\}}t$j$j&�|j'|d%<||d=<|
rKt(|���s)t|d��ntjj)|��}||d
<ntjj|�s�tj|�|j
d+d>d?|d@dA|d+|�ntj*|tj+�s�tj|�|j
d+dB||�n|j,|�|d$<tjj|�r�tj*|tj-�s1tj|�|j
d+dC||�ntj*|tj+�smtj|�|j
d+dD||�n|j,|�|d#<n�tjjtjj.|��s�tj|�|j
d+dEtjj.|�|�ntj*tjj.|�tj-�s(tj|�|j
d+dCtjj.|�|�n|j/r�tjj|�rStj|�nd#|kpp|d$|d#k|d"<|j"d+|jd+d�|�nd} |d$|d#krx	yN|r�tjj|�r�|j0|�} q�n|j1||dF|jdF�Wngtk
rj	}!tjj|�r5	tj|�n|j
d+dG||t2|!�fdHt3j4�|�nXt|d"<n,t|d"<tjj|�r�	tj|�n|dkr
|j||�}||kr
tj|�|j
d+dI|||f|�q
n||jd<|j |j�}||d<|j!||d"�|d"<y|j5|�|dJ<Wntk
rx
d|dJ<nX| r�
| |dK<n|j"d+|jd+d�d?|jd@d�|�dS(LNtusernameturl_usernametaliasestpasswordturl_passwordRttypetstrtrequiredRRtbackuptboolt	sha256sumtdefaultR
tchecksumRtinti
RtrawR=t
argument_spectadd_file_common_argstsupports_check_modetmutually_exclusivetthirstysPThe alias "thirsty" has been deprecated and will be removed, use "force" insteadtversions2.13RRRt
checksum_desttchecksum_srcRics`s!|]}|jdd�VqdS(t:iN(tsplit(t.0titem((sL/usr/lib/python2.7/site-packages/ansible/modules/net_tools/basics/get_url.pys	<genexpr>�st,sXSupplying `headers` as a string is deprecated. Please use dict/hash format for `headers`s2.10RsrThe string representation for the `headers` parameter requires a key:value,key:value syntax to be properly parsed.s	sha256:%sRfisAThe checksum parameter has to be in format <algorithm>:<checksum>shttp://shttps://sftp://s
ic3`s0|]&\}}|jd��kr|VqdS(s./N(tstrip(RhtsRD(tfilename(sL/usr/lib/python2.7/site-packages/ansible/modules/net_tools/basics/get_url.pys	<genexpr>ss/Unable to find a checksum for file '%s' in '%s's\W+isThe checksum format is invalids/file already exists but file attributes changedsfile already existstsrcsRequest failedR!RR"sSource %s is not readablesDestination %s is not writablesDestination %s is not readablesDestination %s does not existt
unsafe_writessfailed to copy %s to %s: %sR%s0The checksum for %s did not match %s; it was %s.tmd5sumtbackup_file(6RtupdatetdicttTrueRtparamsR,t	deprecateR+RGt
isinstanceRgR7R-RRR/t
ValueErrorR.RFtopentrstripR8tlenRtitemsRHtsubtlowerR\R0tdigest_from_filetload_file_common_argumentstset_fs_attributes_if_differentR*tgetmtimeR'tutcfromtimestampR(R)RNtjointaccesstR_OKtsha1tW_OKtdirnameR&tbackup_localtatomic_moveR
R9R:tmd5("R^R<RRRWRRYR[RRR=tresultRtdest_is_dirRt	algorithmtchecksum_urltchecksum_tmpsrct
checksum_infoRDtlinetlinestchecksum_maptpartstcksumtchecksum_mismatchtdestination_checksumt	file_argstmtimeR>ttmpsrcR@RqRE((RmsL/usr/lib/python2.7/site-packages/ansible/modules/net_tools/basics/get_url.pytmain�sF		








	
&


-*(

# 



*


*



&!
&	"!"


&



t__main__(t
__future__RRRRTt
__metaclass__tANSIBLE_METADATAt
DOCUMENTATIONtEXAMPLEStRETURNR'RRHR5R2R9tansible.module_utils.basicRt+ansible.module_utils.six.moves.urllib.parseR	tansible.module_utils._textR
tansible.module_utils.urlsRRRRGRFRNR�t__name__(((sL/usr/lib/python2.7/site-packages/ansible/modules/net_tools/basics/get_url.pyt<module>s.


�5]	2		�

Anons79 File Manager Version 1.0, Coded By Anons79
Email: [email protected]