Anons79 Mini Shell

Directory : /lib/python2.7/site-packages/ansible/modules/files/
Upload File :
Current File : //lib/python2.7/site-packages/ansible/modules/files/copy.pyc

�
�Udac@`s�ddlmZmZmZeZidd6dgd6dd6ZdZd	Zd
Z	ddl
Z
ddlZddlZddl
Z
ddlZ
ddlZddlZddlZddlZddlZddlZddlmZdd
lmZddlmZmZddlmZeade fd��YZ!d�Z"d�Z#d�Z$d�Z%d�Z&d�Z'd�Z(d�Z)e*dkr�e)�ndS(i(tabsolute_importtdivisiontprint_functions1.1tmetadata_versiontstableinterfacetstatustcoretsupported_bys$
---
module: copy
version_added: historical
short_description: Copy files to remote locations
description:
    - The C(copy) module copies a file from the local or remote machine to a location on the remote machine.
    - Use the M(fetch) module to copy files from remote locations to the local box.
    - If you need variable interpolation in copied files, use the M(template) module. Using a variable in the C(content)
      field will result in unpredictable output.
    - For Windows targets, use the M(win_copy) module instead.
options:
  src:
    description:
    - Local path to a file to copy to the remote server.
    - This can be absolute or relative.
    - If path is a directory, it is copied recursively. In this case, if path ends
      with "/", only inside contents of that directory are copied to destination.
      Otherwise, if it does not end with "/", the directory itself with all contents
      is copied. This behavior is similar to the C(rsync) command line tool.
    type: path
  content:
    description:
    - When used instead of C(src), sets the contents of a file directly to the specified value.
    - Works only when C(dest) is a file. Creates the file if it does not exist.
    - For advanced formatting or if C(content) contains a variable, use the M(template) module.
    type: str
    version_added: '1.1'
  dest:
    description:
    - Remote absolute path where the file should be copied to.
    - If C(src) is a directory, this must be a directory too.
    - If C(dest) is a non-existent path and if either C(dest) ends with "/" or C(src) is a directory, C(dest) is created.
    - If I(dest) is a relative path, the starting directory is determined by the remote host.
    - If C(src) and C(dest) are files, the parent directory of C(dest) is not created and the task fails if it does not already exist.
    type: path
    required: yes
  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: '0.7'
  force:
    description:
    - Influence whether the remote file must always be replaced.
    - If C(yes), the remote file will be replaced when contents are different than the source.
    - If C(no), the file will only be transferred if the destination does not exist.
    - Alias C(thirsty) has been deprecated and will be removed in 2.13.
    type: bool
    default: yes
    aliases: [ thirsty ]
    version_added: '1.1'
  mode:
    description:
    - The permissions of the destination file or directory.
    - For those used to C(/usr/bin/chmod) remember that modes are actually octal numbers.
      You must either add a leading zero so that Ansible's YAML parser knows it is an octal number
      (like C(0644) or C(01777))or quote it (like C('644') or C('1777')) so Ansible receives a string
      and can do its own conversion from string into number. Giving Ansible a number without following
      one of these rules will end up with a decimal number which will have unexpected results.
    - As of Ansible 1.8, the mode may be specified as a symbolic mode (for example, C(u+rwx) or C(u=rw,g=r,o=r)).
    - As of Ansible 2.3, the mode may also be the special string C(preserve).
    - C(preserve) means that the file will be given the same permissions as the source file.
    type: path
  directory_mode:
    description:
    - When doing a recursive copy set the mode for the directories.
    - If this is not set we will use the system defaults.
    - The mode is only set on directories which are newly created, and will not affect those that already existed.
    type: raw
    version_added: '1.5'
  remote_src:
    description:
    - Influence whether C(src) needs to be transferred or already is present remotely.
    - If C(no), it will search for C(src) at originating/master machine.
    - If C(yes) it will go to the remote/target machine for the C(src).
    - C(remote_src) supports recursive copying as of version 2.8.
    - C(remote_src) only works with C(mode=preserve) as of version 2.6.
    type: bool
    default: no
    version_added: '2.0'
  follow:
    description:
    - This flag indicates that filesystem links in the destination, if they exist, should be followed.
    type: bool
    default: no
    version_added: '1.8'
  local_follow:
    description:
    - This flag indicates that filesystem links in the source tree, if they exist, should be followed.
    type: bool
    default: yes
    version_added: '2.4'
  checksum:
    description:
    - SHA1 checksum of the file being transferred.
    - Used to validate that the copy of the file was successful.
    - If this is not provided, ansible will use the local calculated checksum of the src file.
    type: str
    version_added: '2.5'
extends_documentation_fragment:
- decrypt
- files
- validate
notes:
- The M(copy) module recursively copy facility does not scale to lots (>hundreds) of files.
seealso:
- module: assemble
- module: fetch
- module: file
- module: synchronize
- module: template
- module: win_copy
author:
- Ansible Core Team
- Michael DeHaan
sd
- name: Copy file with owner and permissions
  copy:
    src: /srv/myfiles/foo.conf
    dest: /etc/foo.conf
    owner: foo
    group: foo
    mode: '0644'

- name: Copy file with owner and permission, using symbolic representation
  copy:
    src: /srv/myfiles/foo.conf
    dest: /etc/foo.conf
    owner: foo
    group: foo
    mode: u=rw,g=r,o=r

- name: Another symbolic mode example, adding some permissions and removing others
  copy:
    src: /srv/myfiles/foo.conf
    dest: /etc/foo.conf
    owner: foo
    group: foo
    mode: u+rw,g-wx,o-rwx

- name: Copy a new "ntp.conf file into place, backing up the original if it differs from the copied version
  copy:
    src: /mine/ntp.conf
    dest: /etc/ntp.conf
    owner: root
    group: root
    mode: '0644'
    backup: yes

- name: Copy a new "sudoers" file into place, after passing validation with visudo
  copy:
    src: /mine/sudoers
    dest: /etc/sudoers
    validate: /usr/sbin/visudo -csf %s

- name: Copy a "sudoers" file on the remote machine for editing
  copy:
    src: /etc/sudoers
    dest: /etc/sudoers.edit
    remote_src: yes
    validate: /usr/sbin/visudo -csf %s

- name: Copy using inline content
  copy:
    content: '# This file was moved to /etc/other.conf'
    dest: /etc/mine.conf

- name: If follow=yes, /path/to/file will be overwritten by contents of foo.conf
  copy:
    src: /etc/foo.conf
    dest: /path/to/link  # link to /path/to/file
    follow: yes

- name: If follow=no, /path/to/link will become a file and be overwritten by contents of foo.conf
  copy:
    src: /etc/foo.conf
    dest: /path/to/link  # link to /path/to/file
    follow: no
s-
dest:
    description: Destination file/path
    returned: success
    type: str
    sample: /path/to/file.txt
src:
    description: Source file used for the copy on the target machine
    returned: changed
    type: str
    sample: /home/httpd/.ansible/tmp/ansible-tmp-1423796390.97-147729857856000/source
md5sum:
    description: MD5 checksum of the file after running copy
    returned: when supported
    type: str
    sample: 2a5aeecc61dc98c4d780b14b330e3282
checksum:
    description: SHA1 checksum of the file after running copy
    returned: success
    type: str
    sample: 6e642bb8dd5c2e027bf21dd923337cbb4214f827
backup_file:
    description: Name of backup file created
    returned: changed and if backup=yes
    type: str
    sample: /path/to/file.txt.2015-02-12@22:09~
gid:
    description: Group id of the file, after execution
    returned: success
    type: int
    sample: 100
group:
    description: Group of the file, after execution
    returned: success
    type: str
    sample: httpd
owner:
    description: Owner of the file, after execution
    returned: success
    type: str
    sample: httpd
uid:
    description: Owner id of the file, after execution
    returned: success
    type: int
    sample: 100
mode:
    description: Permissions of the target, after execution
    returned: success
    type: str
    sample: 0644
size:
    description: Size of the target, after execution
    returned: success
    type: int
    sample: 1220
state:
    description: State of the target, after execution
    returned: success
    type: str
    sample: file
N(t
AnsibleModule(tget_bin_path(tto_bytest	to_native(tPY3tAnsibleModuleErrorcB`seZd�ZRS(cC`s
||_dS(N(tresults(tselfR((s>/usr/lib/python2.7/site-packages/ansible/modules/files/copy.pyt__init__s(t__name__t
__module__R(((s>/usr/lib/python2.7/site-packages/ansible/modules/files/copy.pyR
sc
C`s�tdt�}|d|g}g|D]}t|�^q%}tj|dtdddddd��\}}}|dkr�td	jd
j|�||���ndS(Ntsetfacls-btenviron_updatetLANGtCtLC_ALLtLC_MESSAGESis1Error running "{0}": stdout: "{1}"; stderr: "{2}"t (	R	tTrueR
tmoduletrun_commandtdicttRuntimeErrortformattjoin(tpathRtacl_commandtxt
b_acl_commandtrctoutterr((s>/usr/lib/python2.7/site-packages/ansible/modules/files/copy.pytclear_facls%s3cC`s�tjj|�\}}t|dd�}|dkrCd|gfStjj|�s�|dkrztdidd6��nt|�\}}n
||gfS|j|�||fS(	si
    Return the first pre-existing directory and a list of the new directories that will be created.
    terrorstsurrogate_or_stricttt.t/Rs0The '/' directory doesn't exist on this machine.tmsg(tosR!tsplitR
texistsR
tsplit_pre_existing_dirtappend(tdirnametheadttailtb_headtpre_existing_dirtnew_directory_list((s>/usr/lib/python2.7/site-packages/ansible/modules/files/copy.pyR2/s


cC`s_|r[tjj||jd��}||d<|j||�}t|||||�}n|S(s]
    Walk the new directories list and make sure that permissions are as we would expect
    iR!(R/R!R tpoptset_fs_attributes_if_differentt&adjust_recursive_directory_permissions(R8R9Rtdirectory_argstchangedtworking_dir((s>/usr/lib/python2.7/site-packages/ansible/modules/files/copy.pyR<As
cC`s�t}|jd}|jd}|dk	rd|js?x)tj|�D]�\}}}|j||t�}|tkr~|}nxZg|D]}	tjj	||	�^q�D]0}
|j|
|t�}|tkr�|}q�q�WxZg|D]}tjj	||�^q�D]0}|j||t�}|tkr|}qqWqEWqdt
j|�j}
xtj|�D]�\}}}tj
|�j|
k}|tkr�|}nx]g|D]}	tjj	||	�^q�D]3}
tj
|
�j|
k}|tkr�|}q�q�Wx]g|D]}tjj	||�^qD]3}tj
|�j|
k}|tkr&|}q&q&WqaWn|dk	r�|js�x)tj|�D]�\}}}|j||t�}|tkr�|}nxZg|D]}	tjj	||	�^q�D]0}
|j|
|t�}|tkr�|}q�q�WxZg|D]}tjj	||�^q)D]0}|j||t�}|tkrH|}qHqHWq�Wq�tj|�j}xtj|�D]�\}}}tj
|�j|k}|tkr�|}nx]g|D]}	tjj	||	�^q�D]3}
tj
|
�j|k}|tkr
|}q
q
Wx]g|D]}tjj	||�^qKD]3}tj
|�j|k}|tkrj|}qjqjWq�Wn|S(Ntownertgroup(tFalsetparamstNonet
check_modeR/twalktset_owner_if_differentRR!R tpwdtgetpwnamtpw_uidtstattst_uidtset_group_if_differenttgrptgetgrnamtgr_gidtst_gid(R!RR>R@RAtdirpathtdirnamest	filenamest
owner_changedtdtdirtftfiletuidt
group_changedtgid((s>/usr/lib/python2.7/site-packages/ansible/modules/files/copy.pytchown_recursiveNst

		/
/	/
/		/
/	/
/cC`s`t}|jd}|jd}|jd}tj||�j}t|�rWt}n|js\x�|D]�}tj	j
||�}	tj	j
||�}
t|	dd�}t|
dd�}tj	j|�r�|tkr�tj
|�}
tj|
|�ntj||�|dk	r-|j||t�n|dk	rO|j||t�nt}qgWn|S(NR@RAtlocal_followR)R*(RBRCtfilecmptdircmpt
diff_filestlenRRER/R!R R
tislinktreadlinktsymlinktshutiltcopyfileRDRGRM(tsrctdestRR>R@RAR^Ratitemt
src_item_pathtdest_item_pathtb_src_item_pathtb_dest_item_pathtlinkto((s>/usr/lib/python2.7/site-packages/ansible/modules/files/copy.pytcopy_diff_files�s.


		

cC`st}|jd}|jd}|jd}tj||�j}t|�rWt}n|jsx�|D]�}tj	j
||�}	tj	j
||�}
t|	dd�}t|
dd�}tj	j|�rtj	j
|�r|tkrtj||d|�t||�ntj	j|�rdtj	j
|�rd|tkrdtj|�}
tj|
|�ntj	j|�r�tj	j|�r�|tkr�tj||�|dk	r�|j||t�n|dk	r�|j||t�q�ntj	j|�r=tj	j|�r=|tkr=tj|�}
tj|
|�ntj	j|�r�tj	j|�r�tj||�|dk	r�|j||t�n|dk	r�|j||t�q�ntj	j|�rtj	j
|�rtj||d|�t||�nt}qgWn|S(NR@RAR^R)R*tsymlinks(RBRCR_R`t	left_onlyRbRRER/R!R R
RctisdirRftcopytreeR]RdRetisfileRgRDRGRM(RhRiRR>R@RAR^RrRjRkRlRmRnRo((s>/usr/lib/python2.7/site-packages/ansible/modules/files/copy.pytcopy_left_only�sN


		
0000%%
cC`s�t}tj||�j}x�|D]�}tjj||�}tjj||�}t|dd�}t|dd�}	t||	|�}
t	||	|�}|
s�|r�t
}n|p�ttjj||�tjj||�|�}q"W|S(NR)R*(RBR_R`tcommon_dirsR/R!R R
RpRvRtcopy_common_dirs(RhRiRR>RwRjRkRlRmRntdiff_files_changedtleft_only_changed((s>/usr/lib/python2.7/site-packages/ansible/modules/files/copy.pyRx�s
	:c))C`s�tdtdtdd�dtdd�dtdddt�d	tddd
t�dtddd
t�dtddd
tddg�dtdd�dtdd�dtdd�dtdd�dtdd��dtdt�atjjd�rtjddd�ntjd}t|dd�}tjd	}t	j
j|kredjt	j
j|�}nt|dd�}tjd}tjd}tjjdd�}tjjdd�}tjd}tjd}	tjd }
tjd!}tjd"}tjd}
tjd}t	j
j|�s?tjd#d$|�nt	j|t	j�sktjd#d%|�ntjd d&kr�d'tjt	j|�j�tjd <ntjd }
d}t	j
j|�r�tj|�}nd}y.t	j
j|�rtj|�}nd}Wntk
r+d}nXt}|rc||krctjd#d(d|d)|�n|jt	j�r�|r�t	j
j||�}nt|dd�}t	j
j|�}t|dd�}t	j
j|�s�yt|�\}}Wn?tk
r2}|jd#cd*j|�7<tj|j�nXt	j |�tj!tj�}tjd}|dk	rx||d <n
d|d <t"||t||�q�nt	j
j#|�r�t	j
j$|�}|r�|}nt	j
j||�}t|dd�}nt	j
j|�r�t	j
j%|�rL|rLt	j
j&|�}t'|dd�}n|swtj(d#d+d|d	|d,t�nt	j|t	j�rbt	j
j|�rbtj|�}qbn�t	j
jt	j
j|��sbyt	jt	j
j|��WnNt)k
r>}d-t'|�j*�kr?tjd#d.t	j
j|��q?nXtjd#d/t	j
j|��nt	jt	j
j|�t	j+�r�tjd0r�tjd#d1t	j
j|��nd}||ks�t	j
j%|�r<
tj,s3
y|rt	j
j|�rtj-|�}qnt	j
j%|�rGt	j.|�t/|d2�j0�n|r&|
dk	rotj1||
t�n|dk	r�tj2||t�n|dk	r�tj3||t�nd3|kr�tjd#d4|�ntj4||�\}}}|d5kr&tjd#d6d7|d8|d9|�q&n|}|
r�t	j
j|�r�t5j6d:t	j
j|��\} }t7j8||�yt7j9||�Wq�t)k
r�}|j:t:j;kr�|
d&kr�tj<d;jt'|���q��q�Xnt=r2	t>t	d<�r2	yd=t	j?|�k}!Wq2	t@k
r.	}t}!q2	XntjA||d0tjd0�t=r�	t>t	d<�r�	tBjC�d>kr�	|
r�	|!r�	ytD|�Wq�	tk
r�	}d?t'|�kr�	q�	�q�	tEk
r�	}d@t'|�kr�	q�	�q�	Xq�	nWq3
tFt)fk
r/
tjd#dA||fdBtGjH��q3
Xnt}nt}|dkr�|dkr�|
r�t	j
j#tjd�r�ttjddd�}ttjd	dd�}|jt	j
j�rBt	j
j#tjd	�rBtI||t�}"tJ||t�}#tK||t�}$tL|t�}%|"s6|#s6|$s6|%rBt}qBn|jt	j
j�rt	j
jtjd	�rtt	j
j$|�dd�}&tt	j
j||&�dd�}tt	j
jtjddC�dd�}tj,s�t7jM||dD|	�ntL|t�t}n|jt	j
j�r�
t	j
j#tjd	�r�
tt	j
j$|�dd�}&tt	j
j||&�dd�}tt	j
jtjddC�dd�}tj,r�t	j
j|�r�t7jM||dD|	�t}tL|t�ntj,r
t	j
j|�r
t}nt	j
j|�r�
tI||t�}"tJ||t�}#tK||t�}$tL|t�}%|"s�
|#s�
|$s�
|%r�
t}q�
q�
n|jt	j
j�r�t	j
jtjd	�r�tt	j
j$tjd�dd�}&tt	j
j||&�dd�}tj,r�t	j
j|�r�t	j |�tt	j
jtjddC�dd�}tI||t�}"tJ||t�}#tK||t�}$tL|t�}%|"s�|#s�|$s�|%r�t}q�ntj,r�t	j
j|�r�t}q�q�q�ntd	|d|dE|d|d,|�}'|r-||'dF<n|tjd	<tj,srtj!tj�}(tjN|(|'d,�|'d,<ntj(|'�dS(GNt
argument_specRhttypeR!t_original_basenametstrtcontenttno_logRitrequiredtbackuptbooltdefaulttforcetaliasestthirstytvalidatetdirectory_modetrawt
remote_srcR^tchecksumtadd_file_common_argstsupports_check_modesPThe alias "thirsty" has been deprecated and will be removed, use "force" insteadtversions2.13R)R*s.{0}{1}tfollowtmodeR@RAR.sSource %s not foundsSource %s not readabletpreserves0%03osBCopied file does not match the expected checksum. Transfer failed.texpected_checksums Could not copy to {0}sfile already existsR>spermission denieds*Destination directory %s is not accessibles'Destination directory %s does not existt
unsafe_writessDestination %s not writabletws%ssvalidate must contain %%s: %sisfailed to validatetexit_statuststdouttstderrRWsUnable to copy stats {0}t	listxattrssystem.posix_acl_accesstLinuxRsOperation not supportedsfailed to copy: %s to %st	tracebackR+Rqtmd5sumtbackup_file(ORRRRBRRCtgett	deprecateR
R/R!tsepRRDR1t	fail_jsontaccesstR_OKRKtS_IMODEtst_modeRutsha1tmd5t
ValueErrortendswithR R4R2R
tresultRtmakedirstload_file_common_argumentsR<RstbasenameRctrealpathRt	exit_jsontOSErrortlowertW_OKREtbackup_localtunlinktopentclosetset_mode_if_differentRGRMRttempfiletmkstempRfRgtcopystatterrnotENOSYStwarnRthasattrR�t	Exceptiontatomic_movetplatformtsystemR(RtIOErrorR�t
format_excRpRvRxR]RtR;()Rhtb_srcRitb_destR�R�R}R�R�R^R�R@RAR�R�t
checksum_desttchecksum_srct
md5sum_srcR>R4t	b_dirnameR8R9teR=R�R�R�R%R&R'tb_mysrct_tsrc_has_aclsRyRztcommon_dirs_changedtowner_group_changedt
b_basenametres_argst	file_args((s>/usr/lib/python2.7/site-packages/ansible/modules/files/copy.pytmain�s�	










)



	




	%''#0#	
($

.-	./!(	
	/!(	0%!
(!

	t__main__(+t
__future__RRRR|t
__metaclass__tANSIBLE_METADATAt
DOCUMENTATIONtEXAMPLEStRETURNR�R_RNR/tos.pathR�RHRfRKR�R�tansible.module_utils.basicRt#ansible.module_utils.common.processR	tansible.module_utils._textR
Rtansible.module_utils.sixRRDRR�R
R(R2R<R]RpRvRxR�R(((s>/usr/lib/python2.7/site-packages/ansible/modules/files/copy.pyt<module>sF


wA?		
		
	A		1		�)

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