Dashboard
PHP:
8.2.30
OS:
Linux
User:
dh_nv8b2m
/
/
usr
/
local
/
lib
/
python3.10
/
dist-packages
/
ansible
/
modules
/
__pycache__
📤 Upload
📝 New File
📁 New Folder
Close
Editing: assemble.cpython-310.pyc
o O�h# � @ s� d dl mZ dZdZdZd dlZd dlZd dlZd dlZd dl m Z d dlmZm Z d dlmZ dd d�Zddd �Zdd� ZedkrGe� dS dS )� )�annotationsa� --- 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. M(ansible.builtin.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 V(true)), 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 V(false), it will search for src at originating/master machine. - If V(true), it will go to the remote/target machine for the src. type: bool default: yes version_added: '1.4' regexp: description: - Assemble files only if the given regular expression matches the filename. - If not set, all files are assembled. - Every V(\\) (backslash) must be escaped as V(\\\\) to comply to YAML syntax. - Uses L(Python regular expressions,https://docs.python.org/3/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' attributes: action: support: full async: support: none bypass_host_loop: support: none check_mode: support: none diff_mode: support: full platform: platforms: posix safe_file_operations: support: full vault: support: full version_added: '2.2' seealso: - module: ansible.builtin.copy - module: ansible.builtin.template - module: ansible.windows.win_copy author: - Stephen Fromm (@sfromm) extends_documentation_fragment: - action_common_attributes - action_common_attributes.flow - action_common_attributes.files - decrypt - files a( - name: Assemble from fragments from a directory ansible.builtin.assemble: src: /etc/someapp/fragments dest: /etc/someapp/someapp.conf - name: Insert the provided delimiter between fragments ansible.builtin.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 ansible.builtin.assemble: src: /etc/ssh/conf.d/ dest: /etc/ssh/sshd_config validate: /usr/sbin/sshd -t -f %s �#N)� AnsibleModule)�b� indexbytes)� to_nativeFc C s, t j|d�\}}t�|d�}d}d} tt�| ��D ]v} |r#|�| �s#qtj�| | �}tj� |�r;|r<tj� |��d�r<qt|d��}|� � } W d � n1 sPw Y | r^|�td�� |r||r|t�|�d }|�|� t|d �d kr||�td�� |�| � d}| �td��r�d} qd} q|�� |S )z/ assemble a file from a directory of fragments )�dir�wbF�.�rbN� r ���� T)�tempfile�mkstemp�os�fdopen�sorted�listdir�search�path�join�isfile�basename� startswith�open�read�writer �codecs� escape_decoder �endswith�close)�src_path� delimiter�compiled_regexp� ignore_hidden�tmpdir�tmpfd� temp_path�tmp� delimit_me�add_newline�f�fragment�fragment_fh�fragment_content� r0 �C/usr/local/lib/python3.10/dist-packages/ansible/modules/assemble.py�assemble_from_fragments� s8 " � r2 c C sx t j�| �r:zt �| � W d S ttfy9 } z|d ur.d| t|�f g|d<