관리-도구
편집 파일: fetch.cpython-39.pyc
a �����)g�&����������������������@���s����d�dl�mZmZmZ�eZd�dlZd�dlZd�dlm Z m Z mZ�d�dlm Z mZ�d�dlmZ�d�dlmZ�d�dlmZ�d�dlmZ�d�d lmZmZmZmZ�d�d lmZmZ�e��ZG�dd��de�Z dS�) �����)�absolute_import�division�print_functionN)�AnsibleError�AnsibleActionFail�AnsibleActionSkip)�to_bytes�to_text)�string_types)�boolean)� ActionBase)�Display)�checksum� checksum_s�md5�secure_hash)� makedirs_safe� is_subpathc�����������������������s���e�Zd�Zd��fdd� Z���ZS�)�ActionModuleNc��������������������s`��|du�rt���}tt|���||�}~�z$|�jjr6td��|�jj� dd�}|�jj� dd��}}t |�jj� d�dd�}t |�jj� dd �dd�}t |�jj� d d �dd�} d} t|t�s�d} t|t�s�d } |du�s�|du�r�d} | r�t | ��|�jj�|�}|��|�}i�}d}|�jj�sz|�j||d d�}W�n|�t�y��} �zbd|d<�||d<�|�r\d |d<�t| �|d<�ndt| dd��|d<�|W��Y�d} ~ W�|��|�jjj��S�d} ~ 0�0�|� d�}|� d��r|� d��rd |d<�d|d<�d|d<�|�s�|d��d7��<�|d=�|d=�|W�|��|�jjj��S�d}|dv��r�|�jdt�|d�|d�}|� d��r�|�sV||d<�d|d<�n |�|��d |� dd�v��r|d!|d<�n|� dd��d"��r�d|d<�|W�|��|�jjj��S�|d#�d$k�r�t�|d%��}|du�r�t|�}tjj |�jj�d&d�v�r|�jj�!|�}|�"d'd(�}n|}t#||��s2t d)||f���|�r�tj�$t%|d*d���rd|�&tj ��sdt d+��|�&tj ��r�tj�'|�}tj�(||�}|�d(��s�|�j)�*|�}n2d,|v��r�|d,�}n|�jj+}d-|�j)�*|�||f�}tj�,|�}t-|�}||k�r�t.tj�/|���|du��r |�j�0||��n`z(t1t%|d*d�d.�}|�2|��|�3���W�n6�t4t5f�y~�}�zt d/|���W�Y�d}~n d}~0�0�t6|�}zt7|�}W�n�t8�y����d}Y�n0�| �r�||k�r�|�t�d |d0||d||d1���n|�d ||d||d2���n>zt7|�}W�n�t8�y���d}Y�n0�|�t�d||||d3���W�|��|�jjj��n|��|�jjj��0�|S�)4z handler for fetch operations Nz.check mode not (yet) supported for this module�src�dest�flatF)�strict�fail_on_missingT�validate_checksum��z<Invalid type supplied for source option, it must be a stringz:Invalid type supplied for dest option, it must be a stringzsrc and dest are required)Zall_vars�follow�changed�file�failed�msgz%s, ignoredZsurrogate_or_replace)�errorsr����exists�isdirz<remote file is a directory, fetch cannot work on directoriesz, not transferring, ignored)N�1r���zansible.legacy.slurp)r���)Zmodule_nameZmodule_args� task_varsz not foundz9the remote file does not exist, not transferring, ignoredzsource is a directory�encoding�base64Zcontent�a�\�/zKDetected directory traversal, expected to be contained in '%s' but got '%s'Zsurrogate_or_strictz`dest is an existing directory, use a trailing slash if you want to fetch src into that directoryZinventory_hostnamez%s/%s/%s�wbzFailed to fetch the file: %szchecksum mismatch)r����md5sumr ���r���r���� remote_md5sumr����remote_checksum)r���r,���r���r-���r���r.���)r���r,���r���r���r���)9�dict�superr����runZ _play_contextZ check_moder���Z_task�args�getr���� isinstancer ���r���Z_connectionZ_shellZ join_pathZ_remote_expand_userZbecomeZ_execute_remote_statr���r ���Z_remove_tmp_pathZtmpdirZ_execute_module�update� startswithr'���Z b64decoder����os�path�sepZ_unquote�replacer���r#���r����endswith�basename�joinZ_loaderZ path_dwimZremote_addr�normpathr���r����dirnameZ fetch_file�open�write�close�IOError�OSErrorr���r���� ValueError)�self�tmpr%����result�sourceZ original_destr���r���r���r���r ���Zremote_statr.���ZaeZremote_dataZslurpresZsource_local�baseZtarget_nameZlocal_checksum�f�eZnew_checksumZnew_md5Z local_md5�� __class__���@/usr/lib/python3.9/site-packages/ansible/plugins/action/fetch.pyr1���$���s����� v� c� Q� $ " � � $zActionModule.run)NN)�__name__� __module__�__qualname__r1���� __classcell__rO���rO���rM���rP���r���"���s���r���)!Z __future__r���r���r����typeZ __metaclass__r7���r'���Zansible.errorsr���r���r���Z+ansible.module_utils.common.text.convertersr���r ���Zansible.module_utils.sixr ���Z)ansible.module_utils.parsing.convert_boolr���Zansible.plugins.actionr���Zansible.utils.displayr ���Zansible.utils.hashingr���r���r���r���Zansible.utils.pathr���r���Zdisplayr���rO���rO���rO���rP����<module>���s���