%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3.9/site-packages/ansible/plugins/action/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3.9/site-packages/ansible/plugins/action/__pycache__/__init__.cpython-39.pyc

a

�)g��@svddlmZmZmZeZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlmZmZddlmZddlmZddlmZmZmZmZmZddlmZddlmZm Z dd	l!m"Z"dd
l#m$Z$ddl%m&Z&ddl'm(Z(m)Z)m*Z*dd
l+m,Z,m-Z-m.Z.ddl/m0Z0ddl1m2Z2ddl3m4Z4ddl5m6Z6ddl7m8Z8m9Z9ddl:m;Z;ddl<m=Z=e6�Z>Gdd�de�Z?dS)�)�absolute_import�division�print_functionN)�ABC�abstractmethod)�Sequence)�	constants)�AnsibleError�AnsibleConnectionFailure�AnsibleActionSkip�AnsibleActionFail�AnsibleAuthenticationFailure)�
modify_module)�discover_interpreter�!InterpreterDiscoveryRequiredError)�ArgumentSpecValidator)�UnsupportedError)�_filter_non_json_lines)�binary_type�string_types�	text_type)�to_bytes�	to_native�to_text)�jsonify)�__version__)�resource_from_fqcr)�Display)�wrap_var�AnsibleUnsafeText)�remove_internal_keys)�get_versioned_doclinkc@speZdZdZeg�Zdd�ZedPdd��ZdQdd�Z	dRd
d�Z
dSdd
�ZdTdd�ZdUdd�Z
dVdd�Zdd�Zdd�ZdWdd�Zdd�ZdXdd�Zdd�Zd d!�Zd"d#�Zd$d%�ZdYd&d'�Zd(d)�ZdZd*d+�Zd,d-�Zd.d/�Zd[d1d2�Zd\d3d4�Zd]d5d6�Zd^d7d8�Z d_d9d:�Z!d`d;d<�Z"dad=d>�Z#dbd?d@�Z$dAdB�Z%dCdD�Z&dcdEdF�Z'dGdH�Z(dddJdK�Z)dedLdM�Z*dNdO�Z+dS)f�
ActionBasez�
    This class is the base class for all action plugins, and defines
    code common to all actions. The base class handles the connection
    by putting/getting files and executing commands based on the current
    action in use.
    cCs^||_||_||_||_||_||_d|_d|_d|_d|_	d|_
g|_g|_t
|_d|_dS)NFT)�_task�_connection�
_play_context�_loader�_templar�_shared_loader_obj�_cleanup_remote_tmp�_supports_check_mode�_supports_async�_discovered_interpreter_key�_discovered_interpreter�_discovery_deprecation_warnings�_discovery_warnings�display�_display�_used_interpreter)�selfZtaskZ
connectionZplay_context�loaderZtemplarZshared_loader_obj�r5�C/usr/lib/python3.9/site-packages/ansible/plugins/action/__init__.py�__init__6szActionBase.__init__NcCs�i}|durdg|d<~|jjr0|js0td��n0|jjrH|jsHtd��n|jjr`|jjr`td��|jr�t|jj	�
��}|�|j�}|r�td|jjd�
t|��f��|jjjdur�|��r�|��|S)	a� Action Plugins should implement this method to perform their
        tasks.  Everything else in this base class is a helper method for the
        action plugin to do that.

        :kwarg tmp: Deprecated parameter.  This is no longer used.  An action plugin that calls
            another one and wants to use the same remote tmp for both should set
            self._connection._shell.tmpdir rather than this parameter.
        :kwarg task_vars: The variables (host vars, group vars, config vars,
            etc) associated with this task.
        :returns: dictionary of results from the module

        Implementors of action modules may find the following variables especially useful:

        * Module parameters.  These are stored in self._task.args
        Nz�ActionModule.run() no longer honors the tmp parameter. Action plugins should set self._connection._shell.tmpdir to share the tmpdir�warningz%async is not supported for this task.z*check mode is not supported for this task.z1check mode and async cannot be used on same task.zInvalid options for %s: %s�,)r#�	async_valr+r�
check_moder*r�_VALID_ARGS�	frozenset�args�keys�
difference�action�join�listr$�_shell�tmpdir�_early_needs_tmp_path�_make_tmp_path)r3�tmp�	task_vars�resultZ	task_optsZbad_optsr5r5r6�runMs$


zActionBase.runcCs�|jj��}t||||||d�}|�|�}	|�|	j�z|	jd}
WntyZd}
Yn0|
r�|	jj	}t
|
t�r�d|j�d|��}t
|��|	|fS)aZValidate an argument spec against the task args

        This will return a tuple of (ValidationResult, dict) where the dict
        is the validated, coerced, and normalized task args.

        Be cautious when directly passing ``new_module_args`` directly to a
        module invocation, as it will contain the defaults, and not only
        the args supplied from the task. If you do this, the module
        should not define ``mututally_exclusive`` or similar.

        This code is roughly copied from the ``validate_argument_spec``
        action plugin for use by other action plugins.
        )�mutually_exclusive�required_together�required_one_of�required_if�required_byrNzUnsupported parameters for (z
) module: )r#r>�copyrZvalidate�updateZvalidated_parameters�errors�
IndexError�msg�
isinstancerZ
_load_namer)r3Z
argument_specrLrMrNrOrPZnew_module_argsZ	validatorZvalidation_result�errorrUr5r5r6�validate_argument_spec{s*�


z!ActionBase.validate_argument_specFcCs |s|jjs|�|jjj�dS)a?Method to perform a clean up at the end of an action plugin execution

        By default this is designed to clean up the shell tmpdir, and is toggled based on whether
        async is in use

        Action plugins may override this if they deem necessary, but should still call this method
        via super
        N)r#r:�_remove_tmp_pathr$rDrE)r3�forcer5r5r6�cleanup�s	zActionBase.cleanupc	Cs,z|�|�WSttfy&|YS0dS)z}Helper to get an option from a plugin without having to use
        the try/except dance everywhere to set a default
        N)�
get_option�AttributeError�KeyError)r3Zplugin�option�defaultr5r5r6�get_plugin_option�szActionBase.get_plugin_optioncCs|j|jj||d�S�N�r`)rar$�become�r3r_r`r5r5r6�get_become_option�szActionBase.get_become_optioncCs|j|j||d�Srb)rar$rer5r5r6�get_connection_option�sz ActionBase.get_connection_optioncCs|j|jj||d�Srb)rar$rDrer5r5r6�get_shell_option�szActionBase.get_shell_optioncCs0|jj�|�}|j|dd�}|ddkr,dSdS)NT)�cmd�sudoable�rcrF)r$rD�exists�_low_level_execute_command)r3�pathrirJr5r5r6�_remote_file_exists�s
zActionBase._remote_file_existscCs�|jjr|�d�|jj}n|}|�d�}t|�dkrHd�|dd��nd}t|�}|jjD�]}|dkr�d}	gd�}
|d	vr�||
vr�|jj	|kr�d
|	|f}n|dkr�||
vr�d|	|f}|d
vr�|r�t
|jjd�r�dD]"}||vr�|jj�||�||<q�|j
jj|||jjd�}|j�sP|j�rPt|j�dk�rP|jd}
td�||
���|j}|r\�qnq\td|��t�}|�|�i}|jj�r�d|d<|jjj|d<|jjjd|jd�|d<|jjjd|jd�|d<|jjjd|jd�|d<dD]�}zLt||||jf||jj|jj|t t!|jdd��d �|��\}}}W�q�Wn�t"�y�}z�t#t$||j%|j&|d!��|_'d"|j%}|j'|d#|<|jj�r�|jj(�r�|j'|d#|<||_)n|j'|d|jjd#|<WYd$}~n
d$}~00�q�||||fS)%zu
        Handles the loading and templating of the module code through the
        modify_module() function.
        Zansible_delegated_vars�.�r�z.ps1zansible.windows)zansible.builtinzansible.legacyrr)�stat�filerQZpingz	%s.win_%sZasync_statusz%s.%s)Zwin_statZwin_fileZwin_copyZslurp�_unquote)�src�destrn)Zcollection_list����z@The module {0} was redirected to {1}, which could not be loaded.z6The module %s was not found in configured module pathsTrdZ
become_method�become_user)ZplaycontextZbecome_passZbecome_passwordZbecome_flags)rxrq�_remote_is_localF)rI�module_compressionZ
async_timeout�environmentZremote_is_local)rA�interpreter_name�discovery_moderIzdiscovered_interpreter_%s�
ansible_factsN)*r#Zdelegate_to�get�split�lenrBrr$Z!module_implementation_preferencesrA�hasattrrDrur(Z
module_loaderZfind_plugin_with_context�collectionsZresolvedZ
redirect_listr	�formatZplugin_resolved_path�dict�_compute_environment_stringrd�namer\r%rr'r|r:�bool�getattrrrrr~rr-Zdelegate_factsr,)r3�module_name�module_argsrIZuse_varsZsplit_module_nameZcollection_nameZleaf_module_name�mod_typeZwin_collectionZrewrite_collection_names�keyrJZtarget_module_name�module_path�final_environmentZ
become_kwargsZdummy�module_data�module_styleZmodule_shebangZidreZdiscovered_keyr5r5r6�_configure_module�s�
"�
��



�

�

�
���

4zActionBase._configure_modulecCs�t�}|jjdur~|jj}t|t�s*|g}|D]N}|dus.t|�dkrHq.|j�|�}t|t�srtd|t	|�f��|�
|�q.t|�dkr�|j�|�}t|t�r�|��|�
|�|jj
jfi|��S)zZ
        Builds the environment string to be used when executing the remote task.
        Nrz2environment must be a dictionary, received %s (%s))r�r#r}rVrCr�r'�templater	�typerR�clearr$rDZ
env_prefix)r3Zraw_environment_outr�Zenvironmentsr}Ztemp_environmentr5r5r6r�@s$



z&ActionBase._compute_environment_stringcCst|dd�S)z[
        Determines if a tmp path should be created before the action is executed.
        ZTRANSFERS_FILESF)r��r3r5r5r6rFasz ActionBase._early_needs_tmp_pathc
Cs�z|j�d�}Wn tttfy0|jj}Yn0|jj}|jjrL|jjj	nddk}|jj
|p`||dktj|pt||g}t
|�S)zE
        Determines if we are required and can do pipelining
        �
pipeliningrrZsu�new)r$r\r^r]�
ValueErrorr%r��always_pipeline_modulesrdr�Zhas_pipelining�C�DEFAULT_KEEP_REMOTE_FILES�all)r3r��
wrap_asyncZ
is_enabledZalways_pipelineZbecome_exceptionZ
conditionsr5r5r6�_is_pipelining_enabledhs�	z!ActionBase._is_pipelining_enabledcCs|�ddg�S)zh
        Returns a list of admin users that are configured for the current shell
        plugin
        �admin_users�root)rhr�r5r5r6�_get_admin_users�szActionBase._get_admin_usersc
Csf|�di��d|�d|�dd���}dD]0}z|j�|�}WntyRYq(Yn0qbq(|jj}|S)z= consistently get the 'remote_address' for the action plugin Zdelegated_varsZansible_hostZinventory_hostnameN)�remote_addr�host)r�r$r\r^r%r�)r3�tvarsr�Z	variationr5r5r6�_get_remote_addr�s$
zActionBase._get_remote_addrcCsZd}z|j�d�}Wn@ty<t|jdd�p6|jj}YntyT|jj}Yn0|S)z: consistently get the 'remote_user' for the action plugin N�remote_userZdefault_user)r$r\r^r�r%r�r])r3r�r5r5r6�_get_remote_user�szActionBase._get_remote_usercCs<|jjsdS|��}|��}|�d�}t|o8|||gv�S)z}
        The user is not the same as the connection user and is not part of the
        shell configured admin users
        Frz)r$rdr�r�rfr�)r3r�r�rzr5r5r6�_is_become_unprivileged�s
z"ActionBase._is_become_unprivilegedc
Cs�t|jdd�rtj}n|j|jddd�dd�}|��}|jj��}|jjj	|||d�}|j
|dd�}|dd	k�rN|dd
kr�d}nd|ddkr�|jjd
vr�tj
dkr�d|d|df}q�d}n&d|dvr�|d}nd||df}d|v�r|ddk�r|d|d}tj
dk�rDd|v�rD|ddk�rD|d|d7}t|��nd|_z8|d���d|d�}|jj�|dd���d}	Wnt�y�d}	Yn0|	dk�r�td||f��|	|jj_|	S)zE
        Create and return a temporary path on a remote box.
        r{F�
remote_tmp�~/.ansible/tmprc�rj)�basefile�systemrErkr�zAuthentication failure.�)Zssh�z6SSH encountered an unknown error. The output was:
%s%s�stdout�stderrz�SSH encountered an unknown error during the connection. We recommend you re-run the command using -vvvv, which will enable SSH debugging output to help diagnose the issuezNo space left on devicea5Failed to create temporary directory. In some cases, you may have been able to authenticate and did not have permissions on the target directory. Consider changing the remote tmp path in ansible.cfg to a path rooted in "/tmp", for more error information use -vvv. Failed command was: %s, exited with result %drrz, stdout output: %sz, stderr output: %sTz%s=rxry�/zPfailed to resolve remote temporary directory from %s: `%s` returned empty string)r�r$r��DEFAULT_LOCAL_TMP�_remote_expand_userrhr�rDZ_generate_temp_dir_nameZmkdtemprm�	transportr0�	verbosityr
r)�stripr��	join_path�
splitlinesrTr	rE)
r3r�rEZbecome_unprivilegedr�rirJ�outputZstdout_partsrkr5r5r6rG�sD


�$
 


zActionBase._make_tmp_pathcCs|o|jotjod|vS)zLDetermine if temporary path should be deleted or kept by user request/configz-tmp-)r)r�r�)r3�tmp_pathr5r5r6�_should_remove_tmp_path�sz"ActionBase._should_remove_tmp_pathcCs�|dur|jjjr|jjj}|s*|�|�r�|jjj|dd�}|j|dd�}|�dd�dkr|t�d|�d�|�d	d
�f�n
d|jj_dS)z$Remove a temporary path we created. NT)ZrecurseFr�rkrz;Error deleting remote temporary files (rc: %s, stderr: %s})r�zNo error string available.)	r$rDrEr��removermr�r0r8)r3r�rZriZ
tmp_rm_resr5r5r6rY�s
�zActionBase._remove_tmp_pathcCs|j�||�|S)a�
        Copy a file from the controller to a remote path

        :arg local_path: Path on controller to transfer
        :arg remote_path: Path on the remote system to transfer into

        .. warning::
            * When you use this function you likely want to use use fixup_perms2() on the
              remote_path to make sure that the remote file is readable when the user becomes
              a non-privileged user.
            * If you use fixup_perms2() on the file and copy or move the file into place, you will
              need to then remove filesystem acls on the file once it has been copied into place by
              the module.  See how the copy module implements this for help.
        )r$Zput_file)r3Z
local_path�remote_pathr5r5r6�_transfer_fileszActionBase._transfer_filec
Cs�t|t�rt|�}tjtjd�\}}t�|d�}zt	|dd�}|�
|�Wn4ty~}ztdt
|���WYd}~n
d}~00|��|��z|�||�Wt�|�nt�|�0|S)zJ
        Copies the module data out to the temporary module path.
        )�dir�wb�surrogate_or_strict�rSz>failure writing module data to temporary file for transfer: %sN)rVr�r�tempfileZmkstempr�r��os�fdopenr�write�	Exceptionr	r�flush�closer��unlink)r3r��dataZafdZafileZafo�er5r5r6�_transfer_data#s
&zActionBase._transfer_dataTc
Cs�|dur|��}t|jjdd�r$|S|��sh|rd|�|d�}|ddkrdtd�|dt|d����|S|�	d	�}|r�d
}d}d�|�}d
�|�}	nd}d}d�|�}d�|�}	|�
|||�}|ddkr�|S|�r
|�|d�}|ddk�r
td�|dt|d����|�||�}|ddk�r(|S||��v�r>td��z|�|gt
|�d�}Wn&t�y~}
zWYd}
~
nd}
~
00|ddk�r�|S|�||	�}|ddk�r�|Std�}|�d�}|du�r.|�||�}|ddk�r.|�d��rt�d|�|�rd}
nd}
|�||
�}|ddk�r.|S|�d��r�t�d|�|�|d|�}|ddk�rj|Std�|dt|d����td|dt|d�|f��dS)a%	
        We need the files we upload to be readable (and sometimes executable)
        by the user being sudo'd to but we want to limit other people's access
        (because the files could contain passwords or other private
        information.  We achieve this in one of these ways:

        * If no sudo is performed or the remote_user is sudo'ing to
          themselves, we don't have to change permissions.
        * If the remote_user sudo's to a privileged user (for instance, root),
          we don't have to change permissions
        * If the remote_user sudo's to an unprivileged user then we attempt to
          grant the unprivileged user access via file system acls.
        * If granting file system acls fails we try to change the owner of the
          file with chown which only works in case the remote_user is
          privileged or the remote systems allows chown calls by unprivileged
          users (e.g. HP-UX)
        * If the above fails, we next try 'chmod +a' which is a macOS way of
          setting ACLs on files.
        * If the above fails, we check if ansible_common_remote_group is set.
          If it is, we attempt to chgrp the file to its value. This is useful
          if the remote_user has a group in common with the become_user. As the
          remote_user, we can chgrp the file to that group and allow the
          become_user to read it.
        * If (the chown fails AND ansible_common_remote_group is not set) OR
          (ansible_common_remote_group is set AND the chgrp (or following chmod)
          returned non-zero), we can set the file to be world readable so that
          the second unprivileged user can read the file.
          Since this could allow other users to get access to private
          information we only do this if ansible is configured with
          "allow_world_readable_tmpfiles" in the ansible.cfg. Also note that
          when ansible_common_remote_group is set this final fallback is very
          unlikely to ever be triggered, so long as chgrp was successful. But
          just because the chgrp was successful, does not mean Ansible can
          necessarily access the files (if, for example, the variable was set
          to a group that remote_user is in, and can chgrp to, but does not have
          in common with become_user).
        NZ_IS_WINDOWSFzu+xrkrz=Failed to set execute bit on remote files (rc: {0}, err: {1})r�rz�rxzr-xz{0} allow read,executezA+user:{0}:rx:allowZrXzr-Xz{0} allow readzA+user:{0}:r:allowzLFailed to set file mode or acl on remote temporary files (rc: {0}, err: {1})z�Failed to change ownership of the temporary files Ansible (via chmod nor setfacl) needs to create despite connecting as a privileged user. Unprivileged become user would be unable to read the file.z+azYplaybook_guide/playbooks_privilege_escalation.html#risks-of-becoming-an-unprivileged-userZcommon_remote_groupZworld_readable_tempa�Both common_remote_group and allow_world_readable_tmpfiles are set. chgrp was successful, but there is no guarantee that Ansible will be able to read the files after this operation, particularly if common_remote_group was set to a group of which the unprivileged become user is not a member. In this situation, allow_world_readable_tmpfiles is a no-op. See this URL for more details: %s#risks-of-becoming-an-unprivileged-userzg+rwxzg+rwz�Using world-readable permissions for temporary files Ansible needs to create when becoming an unprivileged user. This may be insecure. For information on securing this, see %s#risks-of-becoming-an-unprivileged-userza+%sz;Failed to set file mode on remote files (rc: {0}, err: {1})z�Failed to set permissions on the temporary files Ansible needs to create when becoming an unprivileged user (rc: %s, err: %s}). For information on working around this, see %s#risks-of-becoming-an-unprivileged-user)r�r�r$rDr��
_remote_chmodr	r�rrf�_remote_set_user_facl�
_remote_chownr�rCr
r!rh�
_remote_chgrpr0r8)r3Zremote_pathsr�Zexecute�resrzZ
chmod_modeZsetfacl_modeZchmod_acl_modeZposix_acl_moder�Zbecome_link�groupZ
group_moder5r5r6�
_fixup_perms2=s�&
��



�
���


	����
�����zActionBase._fixup_perms2cCs"|jj�||�}|j||d�}|S)z.
        Issue a remote chmod command
        r�)r$rD�chmodrm)r3�paths�moderjrir�r5r5r6r�szActionBase._remote_chmodcCs"|jj�||�}|j||d�}|S)z.
        Issue a remote chown command
        r�)r$rD�chownrm)r3r��userrjrir�r5r5r6r�!szActionBase._remote_chowncCs"|jj�||�}|j||d�}|S)z.
        Issue a remote chgrp command
        r�)r$rDZchgrprm)r3r�r�rjrir�r5r5r6r�)szActionBase._remote_chgrpcCs$|jj�|||�}|j||d�}|S)z0
        Issue a remote call to setfacl
        r�)r$rDZ
set_user_faclrm)r3r�r�r�rjrir�r5r5r6r�1sz ActionBase._remote_set_user_faclc	Cs�|durt�d�~t|||dd�}|jd||dd�}|�d�rv|�d	�}|sX|�d
�}|sf|�d�}td||f��|d
ds�d|d
d<d|d
vr�d|d
d<n*t|d
dt�s�tdt|d
d���|d
S)z3
        Get information from remote file.
        Nz�_execute_remote_stat no longer honors the tmp parameter. Action plugins should set self._connection._shell.tmpdir to share the tmpdirZsha1)rn�followZget_checksumZchecksum_algorithmzansible.legacy.statF)r�r�rIr��failed�
module_stderr�
module_stdoutrUz1Failed to get information on remote file (%s): %srsrl�1�checksumrrzDInvalid checksum returned by stat: expected a string type but got %s)	r0r8r��_execute_moduler�r	rVrr�)	r3rn�all_varsr�rHr�r�ZmystatrUr5r5r6�_execute_remote_stat9s4
�
�



zActionBase._execute_remote_statc
Cs�|j�dd�d}z�z2|j|||d�}|dr<|dr<d}n|d}WnXty�}z@t|�}|�d	�rnd
}n|�d�r~d}nd
|vr�d}WYd}~n
d}~00W|S|YS0dS)a�Deprecated. Use _execute_remote_stat() instead.

        Produces a remote checksum given a path,
        Returns a number 0-4 for specific errors instead of checksum, also ensures it is different
        0 = unknown error
        1 = file does not exist, this might not be an error
        2 = permissions issue
        3 = its a directory, not a file
        4 = stat module failed, likely due to not finding python
        5 = appropriate json module not found
        zThe '_remote_checksum()' method is deprecated. The plugin author should update the code to use '_execute_remote_stat()' insteadz2.16�0)r�rl�isdir�3r�zPermission denied�2�MODULE FAILURE�4�json�5N)r1Z
deprecatedr�r	r�endswith)r3rnr�r��xZremote_statr�Zerrormsgr5r5r6�_remote_checksum`s$�

zActionBase._remote_checksumcCsX|�d�s|S|�tjjd�}|d}|dkrr|�d�}t|jdd�rHn*|rb|jjrb|rbd|}nd|�	�pnd}|jj
�|�}|j|dd	�}z|d
�
���d}	Wnty�d}	Yn0|	s�|jj
��}|j|dd	��d
d��
�}
|
r�|
}n|}n2t|�dk�r&|jj
j|	g|dd��R�}n|	}d
tj�|��d�v�rTtd|�i���|S)zK takes a remote path and performs tilde/$HOME expansion on the remote host �~rxrrzr{Fz~%srrr�r�ryNz..r�zE'%s' returned an invalid relative home directory path containing '..')�
startswithr�r�rn�seprfr�r$rdr�rDZexpand_userrmr�r�rT�pwdr�r�r��dirnamer	r�)r3rnrj�pathsepZ
split_pathZexpand_pathrzrir�Zinitial_fragmentr�Zexpandedr5r5r6r��s:



 zActionBase._remote_expand_usercCs |���d�rt�dd|�}|S)zC
        Removes the BECOME-SUCCESS message from the data.
        zBECOME-SUCCESS-z"^((\r)?\n)?BECOME-SUCCESS.*(\r)?\nrr)r�r��re�sub)r3r�r5r5r6�_strip_success_message�sz!ActionBase._strip_success_messagecCs|jjr |jstd��d|d<nd|d<tjjd|d�}|jjpB||d<tj|d<|jj	|d	<t
j|d
<t|d<||d<|�
d
tj�|d<tj|d<tj|d<t|jd�|d<|ds�|�
d�|d<|jj|d<tj|d<|��r�d|d<n|jjj|d<|jddd�|d<dS)Nz.check mode is not supported for this operationTZ_ansible_check_modeFZDEFAULT_NO_TARGET_SYSLOG)Z	variablesZ_ansible_no_logZ_ansible_debugZ
_ansible_diffZ_ansible_verbosityZ_ansible_versionZ_ansible_module_nameZansible_syslog_facilityZ_ansible_syslog_facilityZ_ansible_selinux_special_fsZ!_ansible_string_conversion_actionZsocket_pathZ_ansible_socketZansible_socketZ_ansible_shell_executableZ_ansible_keep_remote_filesZ_ansible_tmpdirr�r�rcZ_ansible_remote_tmp)r#r;r*r	r�ZconfigZget_config_value�no_logZ
DEFAULT_DEBUG�diffr0r�rr�ZDEFAULT_SYSLOG_FACILITYZDEFAULT_SELINUX_SPECIAL_FSZSTRING_CONVERSION_ACTIONr�r$r%�
executabler�r�rDrErh)r3r�r�rIZno_target_syslogr5r5r6�_update_module_args�s0






zActionBase._update_module_argsc&Cs||durt�d�~|dur&t�d�~|jjj}|�d|�sX|durX|��|jjj}|durft�}|durv|jj	}|dur�|jj
}|�|||�d}	|s�|jjr�|j
ddd�}
t|jj�}	|jj�d|
i�|j|||d	�\}}}
}t�d
|�|�s|dk�rtd|��||_d}|�||��sh|du�rF|��|jjj}|jj�|�}|jj�|d
|�}d}|dv�r�|jj�|d�}|�s�|dk�r8t�d|�|dk�r�|�||�n|�||
�|dk�rd}|��D]$\}}|d|t�t|��f7}�q�|�||�n|dv�r.|�|t�|��t�d�|� �}|	du�rT|jj|	=g}|�rl|�rl||g}|�r||�|�d}d}d}|�rx|jj!�sx|jdt�|d	�\}}}}|jj�|�}|jj�||�}|�||�|�|�|jj}dt"�#dd���} |�$dd��%�}!|!|| ||g}"|�r0|"�&d|�|�rB|"�|�n
|"�d�|�'|��sb|"�d�d�(dd �|"D��}n:|�|��r�|
}t�d!�n|}|jjj)||||d"��%�}|�r�d#d$�|D�}|�*||�+��|j,|||d%�}#|�-|#�}$|$�.d&d'��rd'|_/d(|$v�rJt0|$d(t1��r.t0|$d(t2��rJ|$d(|$d)<|$d(=t�d*�t3|$�|�rjd|jj_d|$d+<d,|$v�r�d-|$v�r�|$�4d,d��p�d}%|%�5�|$d-<d.|$v�r�d/|$v�r�|$�4d.d��p�d}%|%�5�|$d/<|j6�r�|$�4d0�du�r�i|$d0<|j7|$d0|j6<|j8�r.|$�4d1�du�rg|$d1<|$d1�9|j8�|j:�r^|$�4d2�du�rNg|$d2<|$d2�9|j:�t;|$�}$t�d3||f�|$S)4zE
        Transfer and run a module along with its arguments.
        Nz�_execute_module no longer honors the tmp parameter. Action plugins should set self._connection._shell.tmpdir to share the tmpdirz�_execute_module no longer honors the delete_remote_tmp parameter. Action plugins should check self._connection._shell.tmpdir to see if a tmpdir existed before they were called to determine if they are responsible for removing it.r��	async_dirz~/.ansible_asyncrcZANSIBLE_ASYNC_DIR)r�r�rIzUsing module file %s�binaryz'module (%s) is missing interpreter linezAnsiballZ_%s)�old�non_native_want_jsonrr>z transferring module to remote %srrrz%s=%s )rrz"done transferring module to remoteTzansible.legacy.async_wrapper�jrl�J)�z#!�_z
-preserve_tmp� css|]}t|�VqdS)N)r��.0r�r5r5r6�	<genexpr>{�z-ActionBase._execute_module.<locals>.<genexpr>zPipelining is enabled.)Zarg_pathcSsg|]}|r|�qSr5r5rr5r5r6�
<listcomp>�rz.ActionBase._execute_module.<locals>.<listcomp>)rj�in_dataZ_ansible_suppress_tmpdir_deleteF�resultsZansible_module_resultszSFound internal 'results' key in module return, renamed to 'ansible_module_results'.Zchangedr��stdout_linesr��stderr_linesr��warningsZdeprecationsz"done with _execute_module (%s, %s))<r0r8r$rDrEr�rGr�r#rAr>rr:rhr�r}�appendr�Zvvvr	r2Zget_remote_filenamer��debugr�r��items�shlex�quoterr��dumpsr�r��randomZrandint�replacer��insertr�rBZbuild_module_commandr�r�rm�_parse_returned_data�popr)rVrrr r�r�r,r-r/�extendr.r)&r3r�r�rHrI�
persist_filesZdelete_remote_tmpr�rEZremove_async_dirrr�Zshebangr�r�Zremote_module_pathZremote_module_filenameZargs_file_pathZ	args_data�k�vZenvironment_stringZremote_filesrjr
riZasync_module_styleZasync_module_dataZasync_module_pathZasync_module_remote_filenameZremote_async_module_pathZasync_limitZ	async_jid�interpreterZ	async_cmdr�r�Ztxtr5r5r6r��s�













�



*

zActionBase._execute_modulecCsLzDt|�dd�dd�\}}|D]}t�|�qt�|�}d|d<W�nt�yFtddd�}|�dd�|d<d	|vr�|d	|d
<|d	�d�r�|d	|d<d|vr�|d�d�r�|d|d<d
|d<|j	du�rt
�|j	�d��}t
�
d|�}|�|d
��s|�|d��rd|d<|dd7<d|v�rB|d|d<Yn0|S)Nr�rrT)Zobjects_only�_ansible_parsedF)r�r"r�r�r�Z	Traceback�	exceptionr�rUz!#z+%s: (?:No such file or directory|not found)zQThe module failed to execute correctly, you probably need to set the interpreter.z&
See stdout/stderr for the exact errorrk)rr�r0r8r��loadsr�r�r�r2r��escape�lstrip�compile�search)r3r�Zfiltered_outputr�wr�r!�matchr5r5r6r�s2
 
zActionBase._parse_returned_data�surrogate_then_replacecCs�t�d�|r0t�d|�|jj�d||�}|r>||jj_|��}|�d�}|r�|jjr�t	|jj
�dkr�tjs�||ks�t
||f�s�t�d�|jj�||jj�}|jjr�|dur�|jj}|jj�|d�}|r�|d	t�|�}t�d
|f�|jj
dk�rt|j��dd
�|j_|jj|||d�\}	}
}t|
t��rHt|
|d
�}n(t|
t��sltd�|
���|d
�}n|
}t|t��r�t||d
�}
n(t|t��s�td�|���|d
�}
n|}
|	du�r�d}	|�|�}t�d|	||
f�t|	||� �|
|
� �d�S)a7
        This is the function which executes the low level shell command, which
        may be commands to create/remove directories for temporary files, or to
        run the module code or python directly when pipelining.

        :kwarg encoding_errors: If the value returned by the command isn't
            utf-8 then we have to figure out how to transform it to unicode.
            If the value is just going to be displayed to the user (or
            discarded) then the default of 'replace' is fine.  If the data is
            used as a key or is going to be written back out to a file
            verbatim, then this won't work.  May have to use some sort of
            replacement strategy (python3 could use surrogateescape)
        :kwarg chdir: cd into this directory before executing the command.
        z&_low_level_execute_command(): startingzA_low_level_execute_command(): changing cwd to %s for this commandzcd %srzZnetwork_cliz;_low_level_execute_command(): using become for this commandNzsleep 0z -c z+_low_level_execute_command(): executing: %s�localr�r�)r
rjrrz>_low_level_execute_command() done: rc=%d, stdout=%s, stderr=%s)rkr�rr�r)!r0rr$rDZappend_commandr�r�rfrdrr�r�ZBECOME_ALLOW_SAME_USER�anyZbuild_become_commandZallow_executabler%rrrr&Zget_basedir�cwdZexec_commandrVrrrrB�	readlinesr�r�r�)r3rirjr
r�Zencoding_errors�chdirZruserZbuserrkr�r��out�errr5r5r6rm�sX


���
�


z%ActionBase._low_level_execute_commandc

Csti}t�d�|jdt|dd�|dd�}|�dd�r`t�dtj�|�|t	|�d	d
��f�|S|�dd�dk�rB|�d
�dvr�d
|d<n�|�d�r�d|d<n�|�d�r�t
jdkr�|dt
jkr�t
j|d<nvt�d|�|jdt|d�|dd�}d|v�rB|d}|ddk�rt�
|�}ntdt|���||d<t	|�|d<|�r(t�|�}	t
jdk�r||	tjt
jk�r|t
j|d<n�t�d|�z8t|d��}
|
��}Wd�n1�s�0YWn:t�y�}z td |t|�f��WYd}~n
d}~00d!|v�rd|d"<n||d#<t	|�|d$<nt�d%�d&|d#<||d$<|jj�rpd|v�r^d
|d<d$|v�rpd'|d$<|S)(Nz4Going to peek to see if file has changed permissionszansible.legacy.fileT)rnZ
_diff_peek)r�r�rIrr�Fz,Failed to get diff between '%s' and '%s': %srUrrrkr�state)NZabsent�beforeZappears_binaryrxZ
dst_binary�sizeZ
dst_largerzSlurping the file %szansible.legacy.slurp)rnZcontent�encoding�base64z.unknown encoding in content option, failed: %sZ
before_headerZ
src_largerz!Reading local copy of the file %s�rbz8Unexpected error while reading source (%s) for diff: %s �Z
src_binaryZafter_headerZafterzsource of file passed inzdynamically generatedzX [[ Diff output has been hidden because 'no_log: true' was specified for this result ]]
)r0rr�r�r�r8r�rn�basenamerr�ZMAX_FILE_SIZE_FOR_DIFFr7Z	b64decoder	rrs�ST_SIZE�open�readr�r#r�)
r3Zdestination�sourcerIZsource_filer�Zpeek_resultZdest_resultZ
dest_contents�strvZsrc_contentsr�r5r5r6�_get_diff_dataCsf
�(


"
�

,*





zActionBase._get_diff_datacCs|j��}|j�|||�S)z�
            find a needle in haystack of paths, optionally using 'dirname' as a subdir.
            This will build the ordered list of paths to search and pass them to dwim
            to get back the first existing file found.
        )r#Zget_search_pathr&Zpath_dwim_relative_stack)r3r�ZneedleZ
path_stackr5r5r6�_find_needle�s
zActionBase._find_needle)NN)NNNNNN)F)N)N)N)N)N)F)N)F)NT)F)F)F)F)NT)F)TN)NNNNFNF)TNNr+N)T),�__name__�
__module__�__qualname__�__doc__r=r<r7rrKrXr[rarfrgrhror�r�rFr�r�r�r�r�rGr�rYr�r�r�r�r�r�r�r�r�r�r�rr�rrmr@rAr5r5r5r6r"*s`-�
2

	


n
!

?

]




'
 
6:
U'
P
Ir")@Z
__future__rrrr�Z
__metaclass__r7r�r�rr�rrsr��abcrr�collections.abcrZansiblerr�Zansible.errorsr	r
rrr
Zansible.executor.module_commonrZ&ansible.executor.interpreter_discoveryrrZ$ansible.module_utils.common.arg_specrZansible.module_utils.errorsrZansible.module_utils.json_utilsrZansible.module_utils.sixrrrZansible.module_utils._textrrrZansible.parsing.utils.jsonifyrZansible.releaserZansible.utils.collection_loaderrZansible.utils.displayrZansible.utils.unsafe_proxyrrZansible.vars.cleanr Zansible.utils.plugin_docsr!r0r"r5r5r5r6�<module>s:

Zerion Mini Shell 1.0