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: unarchive.cpython-310.pyc
o O�hP� � @ sP d dl mZ dZdZdZd dlZd dlZd dlZd dlZd dl Z d dl Z d dlZd dlZd dl Z d dlZd dlZd dlZd dlmZ d dlmZ d dlmZmZmZ d d lmZ d d lmZ d dlmZ d dlm Z zd d l!m"Z" W n e#y� d d l$m"Z" Y nw zd dlm%Z% W n e#y� d dlm&Z% Y nw e �'d�Z(e �'d�Z)e �'d�Z*e �'d�Z+e �'d�Z,e �'d�Z-e �'d�Z.e �'d�Z/e �'d�Z0e �'d�Z1dd� Z2dd� Z3G dd� de4�Z5G d d!� d!e6�Z7G d"d#� d#e6�Z8G d$d%� d%e8�Z9G d&d'� d'e8�Z:G d(d)� d)e8�Z;G d*d+� d+e8�Z<G d,d-� d-e7�Z=d.d/� Z>d0d1� Z?e@d2k�r&e?� dS dS )3� )�annotationsa� --- module: unarchive version_added: '1.4' short_description: Unpacks an archive after (optionally) copying it from the local machine description: - The M(ansible.builtin.unarchive) module unpacks an archive. It will not unpack a compressed file that does not contain an archive. - By default, it will copy the source file from the local system to the target before unpacking. - Set O(remote_src=yes) to unpack an archive which already exists on the target. - If checksum validation is desired, use M(ansible.builtin.get_url) or M(ansible.builtin.uri) instead to fetch the file and set O(remote_src=yes). - For Windows targets, use the M(community.windows.win_unzip) module instead. options: src: description: - If O(remote_src=no) (default), local path to archive file to copy to the target server; can be absolute or relative. If O(remote_src=yes), path on the target server to existing archive file to unpack. - If O(remote_src=yes) and O(src) contains V(://), the remote machine will download the file from the URL first. (version_added 2.0). This is only for simple cases, for full download support use the M(ansible.builtin.get_url) module. type: path required: true dest: description: - Remote absolute path where the archive should be unpacked. - The given path must exist. Base directory is not created by this module. type: path required: true copy: description: - If true, the file is copied from local controller to the managed (remote) node, otherwise, the plugin will look for src archive on the managed machine. - This option has been deprecated in favor of O(remote_src). - This option is mutually exclusive with O(remote_src). type: bool default: yes creates: description: - If the specified absolute path (file or directory) already exists, this step will B(not) be run. - The specified absolute path (file or directory) must be below the base path given with O(dest). type: path version_added: "1.6" io_buffer_size: description: - Size of the volatile memory buffer that is used for extracting files from the archive in bytes. type: int default: 65536 version_added: "2.12" list_files: description: - If set to True, return the list of files that are contained in the tarball. type: bool default: no version_added: "2.0" exclude: description: - List the directory and file entries that you would like to exclude from the unarchive action. - Mutually exclusive with O(include). type: list default: [] elements: str version_added: "2.1" include: description: - List of directory and file entries that you would like to extract from the archive. If O(include) is not empty, only files listed here will be extracted. - Mutually exclusive with O(exclude). type: list default: [] elements: str version_added: "2.11" keep_newer: description: - Do not replace existing files that are newer than files from the archive. type: bool default: no version_added: "2.1" extra_opts: description: - Specify additional options by passing in an array. - Each space-separated command-line option should be a new element of the array. See examples. - Command-line options with multiple elements must use multiple lines in the array, one for each element. type: list elements: str default: [] version_added: "2.1" remote_src: description: - Set to V(true) to indicate the archived file is already on the remote system and not local to the Ansible controller. - This option is mutually exclusive with O(copy). type: bool default: no version_added: "2.2" validate_certs: description: - This only applies if using a https URL as the source of the file. - This should only set to V(false) used on personally controlled sites using self-signed certificate. - Prior to 2.2 the code worked as if this was set to V(true). type: bool default: yes version_added: "2.2" extends_documentation_fragment: - action_common_attributes - action_common_attributes.flow - action_common_attributes.files - decrypt - files attributes: action: support: full async: support: none bypass_host_loop: support: none check_mode: support: partial details: Not supported for gzipped tar files. diff_mode: support: partial details: Uses gtar's C(--diff) arg to calculate if changed or not. If this C(arg) is not supported, it will always unpack the archive. platform: platforms: posix safe_file_operations: support: none vault: support: full todo: - Re-implement tar support using native tarfile module. - Re-implement zip support using native zipfile module. notes: - Requires C(zipinfo) and C(gtar)/C(unzip) command on target host. - Requires C(zstd) command on target host to expand I(.tar.zst) files. - Can handle I(.zip) files using C(unzip) as well as I(.tar), I(.tar.gz), I(.tar.bz2), I(.tar.xz), and I(.tar.zst) files using C(gtar). - Does not handle I(.gz) files, I(.bz2) files, I(.xz), or I(.zst) files that do not contain a I(.tar) archive. - Existing files/directories in the destination which are not in the archive are not touched. This is the same behavior as a normal archive extraction. - Existing files/directories in the destination which are not in the archive are ignored for purposes of deciding if the archive should be unpacked or not. seealso: - module: community.general.archive - module: community.general.iso_extract - module: community.windows.win_unzip author: Michael DeHaan au - name: Extract foo.tgz into /var/lib/foo ansible.builtin.unarchive: src: foo.tgz dest: /var/lib/foo - name: Unarchive a file that is already on the remote machine ansible.builtin.unarchive: src: /tmp/foo.zip dest: /usr/local/bin remote_src: yes - name: Unarchive a file that needs to be downloaded (added in 2.0) ansible.builtin.unarchive: src: https://example.com/example.zip dest: /usr/local/bin remote_src: yes - name: Unarchive a file with extra options ansible.builtin.unarchive: src: /tmp/foo.zip dest: /usr/local/bin extra_opts: - --transform - s/^xxx/yyy/ ab dest: description: Path to the destination directory. returned: always type: str sample: /opt/software files: description: List of all the files in the archive. returned: When O(list_files) is V(True) type: list sample: '["file1", "file2"]' gid: description: Numerical ID of the group that owns the destination directory. returned: always type: int sample: 1000 group: description: Name of the group that owns the destination directory. returned: always type: str sample: "librarians" handler: description: Archive software handler used to extract and decompress the archive. returned: always type: str sample: "TgzArchive" mode: description: String that represents the octal permissions of the destination directory. returned: always type: str sample: "0755" owner: description: Name of the user that owns the destination directory. returned: always type: str sample: "paul" size: description: The size of destination directory in bytes. Does not include the size of files or subdirectories contained within. returned: always type: int sample: 36 src: description: - The source archive's path. - If O(src) was a remote web URL, or from the local ansible controller, this shows the temporary location where the download was stored. returned: always type: str sample: "/home/paul/test.tar.gz" state: description: State of the destination. Effectively always "directory". returned: always type: str sample: "directory" uid: description: Numerical ID of the user that owns the destination directory. returned: always type: int sample: 1000 N)�partial)�ZipFile)�to_bytes� to_native�to_text)� AnsibleModule)�get_bin_path)�get_best_parsable_locale)� fetch_file)�quote)� BadZipFile)� BadZipfilez: Uid differs$z: Gid differs$z: Mode differs$z: Mod time differs$z4: : Warning: Cannot stat: No such file or directory$z2: Warning: Cannot stat: No such file or directory$z([r-][w-][SsTtx-]){3}z: Invalid ownerz: Invalid groupz: Symlink differs$c C sf t �d�}t| d��}tt|j|�d�D ]}t �||�}qW d � |d@ S 1 s*w Y |d@ S )z# Return a CRC32 checksum of a file � �rbNl �� )�binascii�crc32�open�iterr �read)�path�buffer_size�crc�f�b_block� r �D/usr/local/lib/python3.10/dist-packages/ansible/modules/unarchive.pyr s � ��r c C s t �dd| �S )z6 Quote meta-characters in the args for the unix shell z([^A-Za-z0-9_])z\\\1)�re�sub)�stringr r r �shell_escape* s r c @ s e Zd ZdS )�UnarchiveErrorN)�__name__� __module__�__qualname__r r r r r! / s r! c @ sP e Zd Zdd� Zdd� Zdd� Zdd� Zed d � �Zdd� Z d d� Z dd� ZdS )� ZipArchivec C sz || _ || _|| _|jd | _|| _|jd | _|jd | _g | _| jjd | _ d | _ d | _g | _t � | _d| _d| _d S )N� extra_opts�io_buffer_size�exclude�include� )��unzip�cmd_path)�zipinfo�zipinfo_cmd_path)�src�b_dest� file_args�params�opts�moduler'