관리-도구
편집 파일: local.cpython-39.opt-1.pyc
a �����)g; ����������������������@���s����d�dl�mZmZmZ�eZdZd�dlZd�dlZd�dl Z d�dl Z d�dlZd�dlZd�dl mZ�d�dlmZmZ�d�dlmZ�d�dlmZmZ�d�dlmZmZmZ�d�dlmZ�d�d lmZ�d�d l m!Z!�e��Z"G�dd��de�Z#dS�) �����)�absolute_import�division�print_functiona��� name: local short_description: execute on controller description: - This connection plugin allows ansible to execute tasks on the Ansible 'controller' instead of on a remote host. author: ansible (@core) version_added: historical extends_documentation_fragment: - connection_pipelining notes: - The remote user is ignored, the user with which the ansible CLI was executed is used instead. N)�AnsibleError�AnsibleFileNotFound)� selectors)� text_type�binary_type)�to_bytes� to_native�to_text)�ConnectionBase)�Display)�unfrackpathc�����������������������s^���e�Zd�ZdZdZdZ��fdd�Zdd��Zd��fd d � Z��fdd�Z ��fd d�Z dd��Z���ZS�)� Connectionz Local based connections �localTc��������������������sZ���t�t|��j|i�|���d�|�_zt���|�_W�n*�tyT���t� dt ������d|�_Y�n0�d�S�)NzPCurrent user (uid=%s) does not seem to exist on this system, leaving user empty.��)�superr����__init__�cwd�getpassZgetuser�default_user�KeyError�displayZvv�os�getuid)�self�args�kwargs�� __class__���D/usr/lib/python3.9/site-packages/ansible/plugins/connection/local.pyr���.���s����zConnection.__init__c�����������������C���s6���|�j�|�j_|�js2tjd�|�jj�|�jjd��d|�_|�S�)z/ connect to the local host; nothing to do here z(ESTABLISH LOCAL CONNECTION FOR USER: {0}��hostT)r���� _play_contextZremote_user� _connectedr����vvv�format�remote_addr�r���r!���r!���r"����_connect8���s ���� zConnection._connectNc�������������� ������s���t�t|��j|||d��t�d��tjr4tj���d�nd}tj � t|dd��sXtd|���tj d�t|��|�jjd ��t�d ��t|ttf�r�t|�}n tt|�}d}tj}|�r|�j�r|�j����r|��d��szt���\}}W�n<�ttf�y�}�zt�dt|����W�Y�d}~n d}~0�0�tj |t|ttf�||�j!|tjtjd �}|du�rZt�"|��t�d��|�j�rn|�j����rn|�rnt#�#|j$t#j%t#�#|j$t#j&�tj'B���t#�#|j(t#j%t#�#|j(t#j&�tj'B���t)�*��} | �+|j$t)j,��| �+|j(t)j,��d} z�|�j�-| ��s�|�j�.| ��s�| �/|�jj0�}|�s@|�1��\}} tdt| ����|D�]<\}}|j2|j$k�rf|j$�3��}n|j2|j(k�rD|j(�3��}�qD|�s�|�1��\}} tdt| ����| |7�} �q�W�| �"���n | �"���0�|�j�-| ��s"|�jjd|�jd�}|du��r |j4�5t|dd�d���nt�5|t|dd�d���t#�#|j$t#j%t#�#|j$t#j&�tj'�@���t#�#|j(t#j%t#�#|j(t#j&�tj'�@���t�d��|�1|�\}} t�d��|�r�t�"|��t�d��|j6|| fS�)z! run a command on the local host )�in_data�sudoablezin local.exec_command()r���N�surrogate_or_strict��errorsz^failed to find the executable specified %s. Please verify if the executable exists and re-try.zEXEC {0}r#���zopening command with Popen()Z pipeliningzUnable to open pty: %s)�shell� executabler����stdin�stdout�stderrz!done running command with Popen()�����z:timeout waiting for privilege escalation password prompt: z;privilege output closed while waiting for password prompt: �become_pass)Zplaycontext���� z!getting output with communicate()zdone communicatingzdone with local.exec_command())7r���r����exec_commandr����debug�CZDEFAULT_EXECUTABLE�splitr����path�existsr ���r���r'���r(���r���r%���r)���� isinstancer���r ����map� subprocess�PIPEZbecomeZ expect_promptZ get_option�pty�openpty�IOError�OSErrorr����Popenr����close�fcntlr4���ZF_SETFLZF_GETFL� O_NONBLOCKr5���r���ZDefaultSelector�registerZ EVENT_READZ check_successZcheck_password_promptZselect�timeoutZcommunicateZfileobj�readr3����write� returncode)r����cmdr,���r-���r2���Zmasterr3����e�p�selectorZ become_outputZeventsr4���r5����keyZevent�chunkr7���r���r!���r"���r9���D���s����� � &(� $$ && zConnection.exec_commandc�������������� ������s����t�t|���||��t||�jd�}t||�jd�}tjd�||�|�jj d��t j�t |dd��sntd�t|����z t�t |dd�t |dd���W�nf�tjy����td�t|�t|����Y�n<�ty��}�z$td�t|�t|����W�Y�d }~n d }~0�0�d S�) z% transfer a file from local to local )ZbasedirzPUT {0} TO {1}r#���r.���r/���z"file or module does not exist: {0}z(failed to copy: {0} and {1} are the samez#failed to transfer file to {0}: {1}N)r���r����put_filer���r���r���r'���r(���r%���r)���r���r=���r>���r ���r���r����shutil�copyfile�Errorr���rE���)r����in_path�out_pathrQ���r���r!���r"���rV�������s���� zConnection.put_filec��������������������s<���t�t|���||��tjd�||�|�jjd��|��||��dS�)z7 fetch a file from local to local -- for compatibility zFETCH {0} TO {1}r#���N) r���r���� fetch_filer���r'���r(���r%���r)���rV���)r���rZ���r[���r���r!���r"���r\�������s����zConnection.fetch_filec�����������������C���s ���d|�_�dS�)z. terminate the connection; nothing to do here FN)r&���r*���r!���r!���r"���rH�������s����zConnection.close)NT) �__name__� __module__�__qualname__�__doc__Z transportZhas_pipeliningr���r+���r9���rV���r\���rH���� __classcell__r!���r!���r���r"���r���(���s��� br���)$Z __future__r���r���r����typeZ __metaclass__Z DOCUMENTATIONrI���r���r���rC���rW���rA���Zansible.constantsZ constantsr;���Zansible.errorsr���r���Zansible.module_utils.compatr���Zansible.module_utils.sixr���r ���Zansible.module_utils._textr ���r���r���Zansible.plugins.connectionr ���Zansible.utils.displayr���Zansible.utils.pathr���r���r���r!���r!���r!���r"����<module>���s$���