Anons79 Mini Shell

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

�
�Udac@`s�ddlmZmZmZeZidd6dgd6dd6ZdZd	Zdd
l	Z	dd
l
Z
dd
lZdd
lZddl
mZddlmZmZdd
lmZd
d
ed
d�Zd
d�Zd�Zedkr�e�nd
S(i(tabsolute_importtdivisiontprint_functions1.1tmetadata_versiontstableinterfacetstatustcoretsupported_bysj	
---
module: assemble
short_description: Assemble configuration files from fragments
description:
- Assembles a configuration file from fragments.
- Often a particular program will take a single configuration file and does not support a
  C(conf.d) style structure where it is easy to build up the configuration
  from multiple sources. C(assemble) will take a directory of files that can be
  local or have already been transferred to the system, and concatenate them
  together to produce a destination file.
- Files are assembled in string sorting order.
- Puppet calls this idea I(fragments).
version_added: '0.5'
options:
  src:
    description:
    - An already existing directory full of source files.
    type: path
    required: true
  dest:
    description:
    - A file to create using the concatenation of all of the source files.
    type: path
    required: true
  backup:
    description:
    - Create a backup file (if C(yes)), including the timestamp information so
      you can get the original file back if you somehow clobbered it
      incorrectly.
    type: bool
    default: no
  delimiter:
    description:
    - A delimiter to separate the file contents.
    type: str
    version_added: '1.4'
  remote_src:
    description:
    - If C(no), it will search for src at originating/master machine.
    - If C(yes), it will go to the remote/target machine for the src.
    type: bool
    default: no
    version_added: '1.4'
  regexp:
    description:
    - Assemble files only if C(regex) matches the filename.
    - If not set, all files are assembled.
    - Every "\" (backslash) must be escaped as "\\" to comply to YAML syntax.
    - Uses L(Python regular expressions,http://docs.python.org/2/library/re.html).
    type: str
  ignore_hidden:
    description:
    - A boolean that controls if files that start with a '.' will be included or not.
    type: bool
    default: no
    version_added: '2.0'
  validate:
    description:
    - The validation command to run before copying into place.
    - The path to the file to validate is passed in via '%s' which must be present as in the sshd example below.
    - The command is passed securely so shell features like expansion and pipes won't work.
    type: str
    version_added: '2.0'
seealso:
- module: copy
- module: template
- module: win_copy
author:
- Stephen Fromm (@sfromm)
extends_documentation_fragment:
- decrypt
- files
s�
- name: Assemble from fragments from a directory
  assemble:
    src: /etc/someapp/fragments
    dest: /etc/someapp/someapp.conf

- name: Inserted provided delimiter in between each fragment
  assemble:
    src: /etc/someapp/fragments
    dest: /etc/someapp/someapp.conf
    delimiter: '### START FRAGMENT ###'

- name: Assemble a new "sshd_config" file into place, after passing validation with sshd
  assemble:
    src: /etc/ssh/conf.d/
    dest: /etc/ssh/sshd_config
    validate: /usr/sbin/sshd -t -f %s
N(t
AnsibleModule(tbt
indexbytes(t	to_nativec	C`s�tjd|�\}}tj|d�}t}t}	x\ttj|��D]E}
|rn|j|
�rnqLntjj	||
�}tjj
|�sL|r�tjj|�jd�r�qLnt
|d��}|j�}
WdQX|	r�|jtd��n|rZ|rZtj|�d}|j|�t|d�d	krW|jtd��qWqZn|j|
�t}|
jtd��r�t}	qLt}	qLW|j�|S(
s/ assemble a file from a directory of fragments tdirtwbt.trbNs
ii����i
(ttempfiletmkstemptostfdopentFalsetsortedtlistdirtsearchtpathtjointisfiletbasenamet
startswithtopentreadtwriteR	tcodecst
escape_decodeR
tTruetendswithtclose(tsrc_patht	delimitertcompiled_regexpt
ignore_hiddenttmpdirttmpfdt	temp_pathttmpt
delimit_metadd_newlinetftfragmenttfragment_fhtfragment_content((sB/usr/lib/python2.7/site-packages/ansible/modules/files/assemble.pytassemble_from_fragmentsxs64

	

cC`srtjj|�rnytj|�Wqnttfk
rj}|dk	rkd|t|�fg|d<qkqnXndS(Ns#Unable to remove temp file (%s): %stwarnings(RRtexiststremovetIOErrortOSErrortNoneR(Rtresultte((sB/usr/lib/python2.7/site-packages/ansible/modules/files/assemble.pytcleanup�scC`s�tdtdtdddt�dtdd�dtdddt�d	tdd
dt�dtdd
dt�d
tdd�dtdd
dt�dtdd��dt�}t}d}d}|jd}|jd}|jd	}|jd}|jd
}d}	|jd}
|jjdd�}td|d|�}tjj	|�sg|j
dd|�ntjj|�s�|j
dd|�n|dk	r�ytj
|�}	Wq�tjk
r�}
|j
ddt|
�|f�q�Xn|rd|kr|j
dd|�nt|||	|
|j�}|j|�}||d<y|j|�}Wntk
rtd}nX||d<tjj	|�r�|j|�}n||krt|r&|j||�\}}}td|d|d|�|d<|dkr&t|�|j
dd||f�q&n|rN|dk	rN|j|�|d<n|j||d |jd �t}nt||�|j|j�}|j||�|d!<d"|d<|j|�dS(#Nt
argument_spectsrcttypeRtrequiredR&tstrtdesttbackuptbooltdefaultt
remote_srctregexpR(tvalidatetadd_file_common_argstmsgsSource (%s) does not existsSource (%s) is not a directorysInvalid Regexp (%s) in "%s"s%ssvalidate must contain %%s: %stchecksumtmd5sumtrctstdouttstderrt
validationis"failed to validate: rc:%s error:%stbackup_filet
unsafe_writestchangedtOK(RtdictR"RR9tparamstgetRRR5t	fail_jsontisdirtretcompileterrorRR3R)tsha1tmd5t
ValueErrortrun_commandR<tbackup_localtatomic_movetload_file_common_argumentstset_fs_attributes_if_differentt	exit_json(tmoduleRSt	path_hasht	dest_hashR>RBRCR&RGR'R(RHR:R;Rtpathmd5RMtoutterrt	file_args((sB/usr/lib/python2.7/site-packages/ansible/modules/files/assemble.pytmain�sx	





'




 	

t__main__(t
__future__RRRR?t
__metaclass__tANSIBLE_METADATAt
DOCUMENTATIONtEXAMPLESR RRZRtansible.module_utils.basicRtansible.module_utils.sixR	R
tansible.module_utils._textRR9RR3R<Rmt__name__(((sB/usr/lib/python2.7/site-packages/ansible/modules/files/assemble.pyt<module>	s$


K.	S

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