%PDF- %PDF-
Mini Shell

Mini Shell

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

a

�)g5m�
@sVddlmZmZmZeZddlZddlZddlZej	dkrRe
dd�ej�
����dd�Ze�dd	�Ze�dd
lmZddlmZed�Zeed
�kr�e
de��ddlZddlZddlZddlZddlmZmZddlmZz"ddlmZddl m!Z!e!�Z"WnBe#�yFZ$z(e%de$ej&d�e�'d�WYdZ$[$n
dZ$[$00ddlm(Z(ddl)m*Z+ddl,m-Z-m.Z.m/Z/ddl0m1Z1ddl2m3Z3ddl4m5Z5m6Z6ddl7m8Z8ddl9m:Z:ddl;m<Z<m=Z=ddl>m?Z?dd l@mAZAdd!lBmCZCdd"lDmEZEdd#lFmGZGdd$lHmIZIdd%lJmKZKzddlLZLd&ZMWneN�y@d'ZMYn0Gd(d)�d)e�ZOdS)*�)�absolute_import�division�print_functionN)��	zRERROR: Ansible requires Python 3.9 or newer on the controller. Current version: %s�c	Cs�g}tjtjtjfD]L}z|��}Wnty:YqYn0t�|�s|�t	|dd�p\d|�q|r�t
dd�dd�|D����dS)zBCheck stdin/stdout/stderr to make sure they are using blocking IO.�nameNz#%szbERROR: Ansible requires blocking IO on stdin/stdout/stderr. Non-blocking file handles detected: %sz, css|]
}|VqdS)N�)�.0�_ior	r	�8/usr/lib/python3.9/site-packages/ansible/cli/__init__.py�	<genexpr>'�z$check_blocking_io.<locals>.<genexpr>)�sys�stdin�stdout�stderr�fileno�	Exception�os�get_blocking�append�getattr�
SystemExit�join)ZhandlesZhandle�fdr	r	r�check_blocking_ios

�rc
Cs�zt�tjd�t��\}}Wn6tjtfyT}ztd|��WYd}~n
d}~00|rf|��dvrrtd|��t�	�}|��dkr�td|��dS)zmSet the locale to the users default setting and ensure
    the locale and filesystem encoding are UTF-8.
    rz<ERROR: Ansible could not initialize the preferred locale: %sN)�utf-8�utf8zEERROR: Ansible requires the locale encoding to be UTF-8; Detected %s.rzIERROR: Ansible requires the filesystem encoding to be UTF-8; Detected %s.)
�locale�	setlocale�LC_ALL�	getlocale�Error�
ValueErrorr�lowerr�getfilesystemencoding)Zdummy�encoding�eZfs_encr	r	r�initialize_locale-s�r))�version)�LooseVersionZjinja2z3.0zRERROR: Ansible requires Jinja2 3.0 or newer on the controller. Current version: %s)�ABC�abstractmethod)�Path)�	constants)�Displayz	ERROR: %s)�file�)�context)�option_helpers)�AnsibleError�AnsibleOptionsError�AnsibleParserError)�InventoryManager)�string_types)�to_bytes�to_text)�
is_executable)�
DataLoader)�PromptVaultSecret�get_file_vault_secret)�add_all_plugin_dirs)�__version__)�AnsibleCollectionConfig)�_get_collection_name_from_path��unfrackpath)�to_unsafe_text)�VariableManagerTFc@s�eZdZdZdZdZdZd-dd�Zedd	��Z	e
d
d��Ze
d.d
d��Ze
d/dd��Z
e
dd��Ze
dd��Zd0dd�Zed1dd��Zedd��Zdd�Ze
d2dd��Ze
d d!��Ze
d"d#��Ze
d$d%��Ze
d3d'd(��Ze
d)d*��Zed4d+d,��ZdS)5�CLIz# code behind bin/ansible* programs �lessZFRSXFNcCs<|std��||_d|_||_tjr8t�d�r8t�	d�dS)z@
        Base init method for all command line programs
        z%A non-empty list for args is requiredNZdev0z�You are running the development version of Ansible. You should only run Ansible from "devel" if you are modifying the Ansible engine, or trying out features under development. This is a rapidly changing source of code and can become unstable at any point.)
r$�args�parser�callback�CZ
DEVEL_WARNINGrA�endswith�display�warning)�selfrJrLr	r	r�__init__�s�zCLI.__init__cCs�|��t�tt�|jj���tj	r<t�
dttj	��n
t�
d�tjjD]�}|d}|dd}d|dvr�d|dd}nd}|d�
d	�}|d�
d
�}|d�
d�}tjd|||f|||d
�qNdS)z�Run the ansible command

        Subclasses must implement this method.  It does the actual work of
        running an Ansible command.
        zUsing %s as config filez$No config file found; using defaultsr��whyZalternativesz, use %s insteadrr*�date�collection_namez%s option, %s%s)r*rUrVN)�parserOZvvr;�opt_helpr*rK�progrMZCONFIG_FILE�vZconfigZ
DEPRECATED�get�
deprecated)rQr\rrTZaltZverrUrVr	r	r�run�s"
�zCLI.runcCs(d|vrd|fS|�dd�}t|�}|S)N�@rS)�split�tuple)�vault_id�parts�retr	r	r�split_vault_id�s
zCLI.split_vault_idTcCsZ|pg}|pg}|D]}dtj|f}|�|�q|s>|sV|rVdtjdf}|�|�|S)Nz%s@%s�prompt_ask_vault_pass)rM�DEFAULT_VAULT_IDENTITYr)�	vault_ids�vault_password_files�ask_vault_pass�create_new_password�auto_promptZ
password_fileZid_slugr	r	r�build_vault_ids�s
zCLI.build_vault_idscCs"g}i}|pg}tjr"|�tj�|r@ddg|d<ddg|d<ndg|d<dg|d<tj|||||d	�}d}}	|D�]�}
t�|
�\}}|d
v�r|p�tj}
t|||
d�}z|��Wn8t	y�}z t
�d||f��WYd}~n
d}~00d
}	|�|
|f�|�|�qtt
�
d|�zt|||d�}WnLt	�y|}z2t
�d|t|�f�|}WYd}~qtWYd}~n
d}~00z|��WnLt	�y�}z2t
�d|t|�f�|}WYd}~qtWYd}~n
d}~00d
}	|�r�|�||f�n|�tj|f�|�|�qt|�r|	�s|�|S)Nz#New vault password (%(vault_id)s): z+Confirm new vault password (%(vault_id)s): �promptzNew Vault password: zConfirm New Vault password: rezVault password (%(vault_id)s): zVault password: )rk)rmre)�prompt_formatsraz'Error in vault password prompt (%s): %sTzReading vault password file: %s)�filenamera�loaderz*Error getting vault password file (%s): %sz-Error in vault password file loading (%s): %s)rMZDEFAULT_VAULT_PASSWORD_FILErrHrlrdrfr>�loadr5rOrP�set_vault_secretsZvvvvvr?r;)rprgrhrirjrk�
vault_secretsrnZlast_exceptionZfound_vault_secretZ
vault_id_slugZ
vault_id_nameZvault_id_valueZbuilt_vault_idZprompted_vault_secret�excZfile_vault_secretr	r	r�setup_vault_secrets�sz��


�


�
�
""zCLI.setup_vault_secretscCstj|d�}|rt|�}|S)N)rm)�getpassrF)rm�secretr	r	r�_get_secret?szCLI._get_secretcCs�tj}d}d}d}tjrdn
|d��}z|d|}|drNt�d�}d|}n|d	rdt�|d	�}|d
r�t�|�}|dr�|dkr�|}n|dr�t�|d�}Wnty�Yn0||fS)z6 prompt for connection and become passwords if needed NrZBECOMEZ
become_methodz
%s password: Zask_passzSSH password: z'%s password[defaults to SSH password]: Zconnection_password_fileZbecome_ask_passZbecome_password_file)	r3�CLIARGSrMZAGNOSTIC_BECOME_PROMPT�upperrHrx�get_password_from_file�EOFError)�opZsshpassZ
becomepassZ
become_promptZbecome_prompt_methodr	r	r�
ask_passwordsGs*


zCLI.ask_passwordscCs|r|jdkr|j�d�|S)z check for conflicting options rSz.The number of processes (--forks) must be >= 1)ZforksrK�error)rQr}Z
runas_optsZ	fork_optsr	r	r�validate_conflictsfs
zCLI.validate_conflictsrcCstj|j|||d�|_dS)a_
        Create an options parser for most ansible scripts

        Subclasses need to implement this method.  They will usually call the base class's
        init_parser to create a basic version and then add their own options on top of that.

        An implementation will look something like this::

            def init_parser(self):
                super(MyCLI, self).init_parser(usage="My Ansible CLI", inventory_opts=True)
                ansible.arguments.option_helpers.add_runas_options(self.parser)
                self.parser.add_option('--my-option', dest='my_option', action='store')
        )�usage�desc�epilogN)rXZcreate_base_parserrrK)rQr�r�r�r	r	r�init_parseroszCLI.init_parsercCs�t|d�r|jsdg|_t|d�rb|jrbt�}|jD]"}|�d�D]}|�|���qBq4t|�|_t|d�r�|jr�t�}|jD]"}|�d�D]}|�|���q�q~t|�|_t|d�r�|js�|j	r�t
|j	t�r�|j	g|_	dd�|j	D�|_	ntj
|_	|S)a
Process the command line args

        Subclasses need to implement this method.  This method validates and transforms the command
        line arguments.  It can be used to check whether conflicting values were given, whether filenames
        exist, etc.

        An implementation will look something like this::

            def post_process_args(self, options):
                options = super(MyCLI, self).post_process_args(options)
                if options.addition and options.subtraction:
                    raise AnsibleOptionsError('Only one of --addition and --subtraction can be specified')
                if isinstance(options.listofhosts, string_types):
                    options.listofhosts = string_types.split(',')
                return options
        �tags�all�,�	skip_tags�	inventorycSs$g|]}d|vrt|dd�n|�qS)r�F)�followrD)r
�optr	r	r�
<listcomp>�rz)CLI.post_process_args.<locals>.<listcomp>)�hasattrr��setr_�add�strip�listr��SKIP_INVENTORY_DEFAULTSr��
isinstancer9rMZDEFAULT_HOST_LIST)rQ�optionsr�Ztag_set�tagr�r	r	r�post_process_args�s*




zCLI.post_process_argsc
Cs�|��trt�|j�z|j�|jdd��}WnJty|}z2|jdkrf|jj	dd|j�
�d��WYd}~n
d}~00|�|�}t�
|�dS)a�Parse the command line args

        This method parses the command line arguments.  It uses the parser
        stored in the self.parser attribute and saves the args and options in
        context.CLIARGS.

        Subclasses need to implement two helper methods, init_parser() and post_process_args() which
        are called from this function before and after parsing the arguments.
        rSNr�z 
%s)�status�message)r��HAS_ARGCOMPLETE�argcompleteZautocompleterK�
parse_argsrJr�code�exit�format_helpr�r3Z_init_global_context)rQr��exr	r	rrW�s


z	CLI.parsec	Cs�|rt��}nt}|��d}|�d�}tt|��D]@}||dkrLd||<zt||�||<Wq4tyrYq40q4t|�dkr�tt|�d�D]}|�d�q�|�	�||d|d|dd�S)z" return full ansible version info r�.rrrSr�)�stringZfull�major�minorZrevision)
rXr*rAr_�range�len�intrrr�)�gitinfoZansible_version_stringZansible_versionZansible_versionsZcounterr	r	r�version_info�s*

�zCLI.version_infocCs�tj��stj|dd�n|dtjvrRtjdkr>tj|dd�q�t�|tjd�nDt	j
ddt	jt	jd�}|��|j
dkr�t�|d�ntj|dd�d	S)
z% find reasonable way to display text T)Zscreen_only�PAGER�win32zless --version)�shellrrrrIN)rr�isattyrOr�environ�platformrH�
pager_pipe�
subprocess�Popen�PIPE�communicate�
returncode)�text�pr	r	r�pager�s



z	CLI.pagercCshdtjvrtjtjd<z*tj|dtjtjd�}|j	t
|�d�Wn"tyRYntybYn0dS)z pipe text through a pager �LESST)r�rr)�inputN)
rr�rH�	LESS_OPTSr�r�r�rrr�r:�IOError�KeyboardInterrupt)r��cmdr	r	rr��s
zCLI.pager_pipec	Cs�tj}t�}|�dd�}|rV|�|�t|�|t_t|�}|rVt	�
d�|��|t_t
|d�}tj}||}tj||t
|d�|ddd�}|�|�t||d|�d	�d
�}t||tjdd�d�}|||fS)
N�basedirFz#running with default collection {0}rgrhri)rgrhrirkr�Zflush_cache)rpZsources�cache)r�)rpr�r�)r3ryr=r[Zset_basedirr@rBZplaybook_pathsrCrOrP�format�default_collectionr�rMZDEFAULT_VAULT_IDENTITY_LISTrHrurrr8rGr�)	r�rpr�r�rgZdefault_vault_idsrsr�Zvariable_managerr	r	r�
_play_prereqss0

�
zCLI._play_prereqsr�cCs^d}t|���dkr2tjr.|tjvr.t�d�d}|�|�|�|�}|sZ|durZtd��|S)NFrzpprovided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'TzSSpecified inventory, host pattern and/or --limit leaves us with no hosts to target.)	r�Z
list_hostsrMZLOCALHOST_WARNINGZ	LOCALHOSTrOrP�subsetr5)r�r��patternZno_hosts�hostsr	r	r�
get_host_list0s


zCLI.get_host_listc	
Cs^t|�}d}|dkr$tjj��}�ntj�|�s>td|��n�t	|�r�t
�dt|��|g}zt
j|t
jt
jd�}Wn4ty�}ztd||f��WYd}~n
d}~00|��\}}|jdkr�td||j|f��|}n^z"t|d�}|����}|��Wn:ttf�y8}ztd	||f��WYd}~n
d}~00|�d
�}|�sVtd|��t|�S)N�-z"The password file %s was not foundz!The password file %s is a script.)rrz�Problem occured when trying to run the password script %s (%s). If this is not a script, remove the executable bit from the file.rz4The password script %s returned an error (rc=%s): %s�rbz#Could not read password file %s: %ss
z*Empty password was provided from file (%s))r:rr�buffer�readr�path�existsr5r<rOZvvvvr;r�r�r��OSErrorr�r��openr��closer�rF)	Zpwd_fileZ
b_pwd_filerwr�r�r(rr�fr	r	rr{Bs:�

&
zCLI.get_password_from_filec
Cs�|durtj}z�t�d�ttj���}z|jdd�WnJt	y�}z2|j
t
jkrnt�d|t
|dd�f�WYd}~nd}~00t�d|�zdd	�|D�}Wn6ty�t�d
�t�dt
t����d}Yn0||�}|��}W�n�t�y8}z.|j��tjt
|�d
d�d}WYd}~�n�d}~0t�yt}z$tjt
|�d
d�d}WYd}~�nLd}~0t�y�}z$tjt
|�d
d�d}WYd}~�nd}~0t�y�t�d�d}Yn�t�y�}z�tj�r�ttj�}tjdt
|�d
d�|�r&|�rvtjddk�rvd
}t|d��r�t�dt
t |j!���t
|j!�}	t
|�|	k�r�t�d|	�nt�d�d}tjdt
t���|d�d}WYd}~n
d}~00t�"|�dS)Nzstarting runi�)�modez'Failed to create the directory '%s': %sZsurrogate_or_replace��errorszCreated the '%s' directorycSsg|]}t|dd��qS)Zsurrogate_or_strictr�)r;)r
�ar	r	rr��rz$CLI.cli_executor.<locals>.<listcomp>zaCommand line args are not in utf-8, unable to continue.  Ansible currently only understands utf-8zThe full traceback was:

%s�F)Z	wrap_textr2�rSzUser interrupted execution�cz0Unexpected Exception, this is probably a bug: %s�	verbosityr��orig_excz
exception type: %sz
original msg: %sz#to see the full traceback, use -vvvTzthe full traceback was:

%s)�log_only�)#r�argvrO�debugr.rMZANSIBLE_HOME�
expanduser�mkdirr��errnoZEEXISTrPr;�UnicodeErrorr�	traceback�
format_excr]r6rK�
print_helpr7r5r�rZ
DEFAULT_DEBUG�boolr3ryr�Zvvv�typer�r�)
�clsrJZansible_dirrtZ	exit_codeZclir(Zhave_cli_optionsr�rTr	r	r�cli_executorlsf
�






zCLI.cli_executor)N)NNNT)NNFT)FF)rNN)F)r�)N)�__name__�
__module__�__qualname__�__doc__r�r�r�rRr-r]�staticmethodrdrlrurxr~r�r�r�rWr�r�r�r�r�r{�classmethodr�r	r	r	rrHwsV



��f


	
8


$
)rH)PZ
__future__rrrr�Z
__metaclass__rrrr�rrr*�
splitlinesrr)�importlib.metadataZ#ansible.module_utils.compat.versionr+Zjinja2_versionr�rvr�r��abcr,r-�pathlibr.Zansibler/rMZansible.utils.displayr0rOrr(�printrr�r3Zansible.cli.argumentsr4rXZansible.errorsr5r6r7Zansible.inventory.managerr8Zansible.module_utils.sixr9Zansible.module_utils._textr:r;Z ansible.module_utils.common.filer<Zansible.parsing.dataloaderr=Zansible.parsing.vaultr>r?Zansible.plugins.loaderr@Zansible.releaserAZansible.utils.collection_loaderrBZ2ansible.utils.collection_loader._collection_finderrCZansible.utils.pathrEZansible.utils.unsafe_proxyrFZansible.vars.managerrGr�r��ImportErrorrHr	r	r	r�<module>st
����
 


Zerion Mini Shell 1.0