HEX
Server: LiteSpeed
System: Linux kapuas.iixcp.rumahweb.net 5.14.0-427.42.1.el9_4.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Nov 1 14:58:02 EDT 2024 x86_64
User: mirz4654 (1666)
PHP: 8.1.33
Disabled: system,exec,escapeshellarg,escapeshellcmd,passthru,proc_close,proc_get_status,proc_nice,proc_open,proc_terminate,shell_exec,popen,pclose,dl,pfsockopen,leak,apache_child_terminate,posix_kill,posix_mkfifo,posix_setsid,posix_setuid,posix_setpgid,ini_alter,show_source,define_syslog_variables,symlink,syslog,openlog,openlog,closelog,ocinumcols,listen,chgrp,apache_note,apache_setenv,debugger_on,debugger_off,ftp_exec,dll,ftp,myshellexec,socket_bind,mail,posix_getwpuid
Upload Files
File: //usr/lib/python3.9/site-packages/ansible/cli/__pycache__/console.cpython-39.pyc
a

�)g�U�@s0ddlmZmZmZeZddlmZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlmZddlmZddlmZddlmZddlmZmZdd	lmZdd
lmZddlmZddl m!Z!dd
l"m#Z#m$Z$ddl%m&Z&ddl'm(Z(ddl)m*Z*e*�Z+Gdd�dee	j,�Z-ddd�Z.e/dk�r,e.�dS)�)�absolute_import�division�print_function)�CLIN)�	constants)�context)�option_helpers)�TaskQueueManager)�	to_native�to_text)�boolean)�parse_kv)�Play)�list_plugins)�
module_loader�fragment_loader)�plugin_docs)�stringc)�Displaycs�eZdZdZdZgZddiZejp&ej	Z
�fdd�Z�fdd�Z�fd	d
�Z
dd�Zd
d�Zdd�Zdd�Zdfdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd d!�ZeZeZd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Z d.d/�Z!d0d1�Z"d2d3�Z#d4d5�Z$d6d7�Z%d8d9�Z&d:d;�Z'd<d=�Z(d>d?�Z)d@dA�Z*dBdC�Z+dDdE�Z,dFdG�Z-dHdI�Z.dJdK�Z/dLdM�Z0dNdO�Z1dPdQ�Z2dRdS�Z3dTdU�Z4dVdW�Z5e4Z6e5Z7dXdY�Z8dZd[�Z9d\d]�Z:d^d_�Z;d`da�Z<�fdbdc�Z=ddde�Z>�Z?S)g�
ConsoleCLIa�
       A REPL that allows for running ad-hoc tasks against a chosen inventory
       from a nice shell with built-in tab completion (based on dominis'
       ansible-shell).

       It supports several commands, and you can modify its configuration at
       runtime:

       - `cd [pattern]`: change host/group (you can use host patterns eg.: app*.dc*:!app01*)
       - `list`: list available hosts in the current path
       - `list groups`: list groups included in the current path
       - `become`: toggle the become flag
       - `!`: forces shell module instead of the ansible module (!yum update -y)
       - `verbosity [num]`: set the verbosity level
       - `forks [num]`: set the number of forks
       - `become_user [user]`: set the become_user
       - `remote_user [user]`: set the remote_user
       - `become_method [method]`: set the privilege escalation method
       - `check [bool]`: toggle check mode
       - `diff [bool]`: toggle diff mode
       - `timeout [integer]`: set the timeout of tasks in seconds (0 to disable)
       - `help [command/module]`: display documentation for the command or module
       - `exit`: exit ansible-console
    zansible-consolezhost-patternz�A name of a group in the inventory, a shell-like glob selecting hosts in inventory or any combination of the two separated by commas.cs�tt|��|�d|_g|_g|_d|_d|_d|_t	�|_
d|_d|_d|_
d|_d|_d|_d|_d|_d|_d|_tj�|�dS)NzAWelcome to the ansible console. Type help or ? to list commands.
�*)�superr�__init__Zintro�groups�hosts�pattern�variable_manager�loader�dict�	passwords�cwd�remote_user�become�become_user�
become_method�
check_mode�diff�forks�task_timeout�collections�cmd�Cmd��self�args��	__class__��7/usr/lib/python3.9/site-packages/ansible/cli/console.pyrHs&zConsoleCLI.__init__cs�tt|�jddd�t�|j�t�|j�t�|j�t�|j�t�	|j�t�
|j�t�|j�t�|j�t�
|j�t�|j�|jjdddddd�|jjd	d
ddd
�dS)Nz)REPL console for executing Ansible tasks.zgThis is not a live session/connection: each task is executed in the background and returns its results.)Zdesc�epilogrzhost pattern�all�?)�help�metavar�default�nargsz--step�step�
store_truez4one-step-at-a-time: confirm each task before running)�dest�actionr6)rr�init_parser�opt_helpZadd_runas_options�parserZadd_inventory_optionsZadd_connect_optionsZadd_check_optionsZadd_vault_optionsZadd_fork_optionsZadd_module_optionsZadd_basedir_optionsZadd_runtask_optionsZadd_tasknoplay_options�add_argument�r-r/r1r2r>ds$
��zConsoleCLI.init_parsercs,tt|��|�}|jt_|j|ddd�|S)NT)Z
runas_optsZ	fork_opts)rr�post_process_args�	verbosity�displayZvalidate_conflicts)r-�optionsr/r1r2rCyszConsoleCLI.post_process_argscCst|�S�N)�dirrBr1r1r2�	get_namesszConsoleCLI.get_namescCsTztj�|�Wn>ty*|��Yn&tyN|�d�|�|�Yn0dS)Nz[Ansible-console was exited])r*r+�cmdloop�KeyboardInterrupt�EOFErrorrE�do_exitrBr1r1r2rJ�s
zConsoleCLI.cmdloopcCsz|jpt��}|j�|j�|_d||jt|j�|jf}|j	rX|j
dvrX|d7}tj}n|d7}|j
}t||dd�|_dS)Nz%s@%s (%d)[f:%s])N�rootz# z$ T)Zwrap_nonvisible_chars)r!�getpassZgetuser�	inventory�
list_hostsr �selected�lenr'r"r#�CZCOLOR_ERROR�
NORMAL_PROMPTr�prompt)r-Z
login_userrVZcolorr1r1r2�
set_prompt�szConsoleCLI.set_promptcCstd|j�S)N�module)rr)rBr1r1r2�list_modules�szConsoleCLI.list_modulesFc
Csh|�d�rdS|js"t�d�dSd}|}|dur`|��^}}t�|�r`|}|r\d�|�}nd}|jrn|j}nt	j
r�t	jdkr�t	j}nd	}d
}zr|t	jv}	t
t
|t||	d�d�|jd
�}
t
d|jd|
g|j|j|j|j|j|j|jd�}t�j||j|jd�}Wn:t�y:}
z t�dt|
��WYd
}
~
dSd
}
~
00z�d
|_zdt|j|j|j|j |t	j
d|j!d�|_|j�"|�}t�#|�W|j�r�|j�$�|j�r�|j�%�n&|j�r�|j�$�|j�r�|j�%�0|d
u�r�t�d�WdSWnvt&�yt�d�YdSt�yb}
z>|j'dk�r>dd
l(}t�)|�*��t�t|
��WYd
}
~
dSd
}
~
00d
S)z actually runs modules �#Fz
No host found�shellT� �r8ZminimalN)�	check_raw)rXr.)r=�timeoutz
Ansible Shell�no)�namerZgather_factsZtasksr!r"r#r$r%r&r))rrzUnable to build command: %s)rPrrrZstdout_callbackZrun_additional_callbacksZrun_treer'zNo hosts foundzUser interrupted execution�r)+�
startswithr rE�error�splitr�find_plugin�join�callbackrTZDEFAULT_LOAD_CALLBACK_PLUGINSZDEFAULT_STDOUT_CALLBACKZ_ACTION_ALLOWS_RAW_ARGSrr
r(r!r"r#r$r%r&r)r�loadrr�	ExceptionrZ_tqmr	rPrr'�run�debugZcleanupZcleanup_all_tmp_filesrKrD�	traceback�v�
format_exc)r-�lineZ
forceshellrX�module_argsZpossible_moduleZ
possible_args�cb�resultr^ZtaskZplay_dsZplay�ermr1r1r2r8�s�



�
�
�




zConsoleCLI.defaultcCsdSrGr1rBr1r1r2�	emptyline�szConsoleCLI.emptylinecCs|�|d�dS)a
        You can run shell commands through the shell module.

        eg.:
        shell ps uax | grep java | wc -l
        shell killall python
        shell halt -n

        You can use the ! to force the shell module. eg.:
        !ps aux | grep java | wc -l
        TN�r8�r-�argr1r1r2�do_shell�szConsoleCLI.do_shellcCst�d�dS)Nz4You can run shell commands through the shell module.�rErBr1r1r2�
help_shellszConsoleCLI.help_shellcCsf|rZzt|�}Wn$ty4t�d�|��Yn0|dkrN||_|��qbt�d�n|��dS)zSet the number of forkszInvalid argument for "forks"rz(forks must be greater than or equal to 1N)�int�	TypeErrorrErd�usage_forksr'rW)r-rxr'r1r1r2�do_forkss

zConsoleCLI.do_forkscCst�d�|��dS)Nz'Set the number of forks to use per task)rEr~rBr1r1r2�
help_forkss
zConsoleCLI.help_forkscCst�d�dS)NzUsage: forks <number>rzrBr1r1r2r~szConsoleCLI.usage_forkscCs~|dvrd|_nB|s|��n4|�d�}|D]$}|jdur@g|_|j�|���q,|jrpt�dd�|j��n
t�d�dS)z.Set list of collections for 'short name' usage)r]ZnoneN�,z%Collections name search is set to: %sz, z)Collections name search is using defaults)r)�usage_collectionsre�append�striprErnrg)r-rxr)Z
collectionr1r1r2�do_collections$s


zConsoleCLI.do_collectionscCst�d�|��dS)NzFSet the collection name search path when using short names for plugins)rEr�rBr1r1r2�help_collections6s
zConsoleCLI.help_collectionscCst�d�dS)NzgUsage: collections <collection1>[, <collection2> ...]
 Use empty quotes or "none" to reset to default.
rzrBr1r1r2r�:szConsoleCLI.usage_collectionsc
Csl|st�d�nXzt|�t_t�d|�Wn:ttfyf}zt�dt|��WYd}~n
d}~00dS)zSet verbosity levelzUsage: verbosity <number>zverbosity level set to %sz)The verbosity must be a valid integer: %sN)rEr|rDrnr}�
ValueErrorrdr)r-rxrtr1r1r2�do_verbosity=s
zConsoleCLI.do_verbositycCst�d�dS)Nz@Set the verbosity level, equivalent to -v for 1 and -vvvv for 4.rzrBr1r1r2�help_verbosityHszConsoleCLI.help_verbositycCsF|sd|_n.|dvrd|_n|j�|�r0||_n
t�d�|��dS)a
            Change active host/group. You can use hosts patterns as well eg.:
            cd webservers
            cd webservers:dbservers
            cd webservers:!phoenix
            cd webservers:&staging
            cd webservers:dbservers:&staging:!phoenix
        rz/*r4zno host matchedN)r rPZ	get_hostsrErWrwr1r1r2�do_cdKs	
zConsoleCLI.do_cdcCst�d�|��dS)NzChange active host/group. )rE�usage_cdrBr1r1r2�help_cd_s
zConsoleCLI.help_cdcCst�d�dS)Nz'Usage: cd <group>|<host>|<host pattern>rzrBr1r1r2r�cszConsoleCLI.usage_cdcCsT|s|jD]}t�|j�q
n2|dkr>|jD]}t�|�q,nt�d�|��dS)z#List the hosts in the current grouprzInvalid option passed to "list"N)rRrErarrd�	help_list)r-rx�host�groupr1r1r2�do_listfs


zConsoleCLI.do_listcCst�d�dS)NzLList the hosts in the current group or a list of groups if you add 'groups'.rzrBr1r1r2r�rszConsoleCLI.help_listcCs:|r,t|dd�|_t�d|j�|��n
t�d�dS)z$Toggle whether plays run with becomeF��strictzbecome changed to %sz.Please specify become value, e.g. `become yes`N)rr"rErnrWrwr1r1r2�	do_becomeus

zConsoleCLI.do_becomecCst�d�dS)Nz,Toggle whether the tasks are run with becomerzrBr1r1r2�help_become~szConsoleCLI.help_becomecCs"|r||_|��n
t�d�dS)z6Given a username, set the remote user plays are run byz5Please specify a remote user, e.g. `remote_user root`N)r!rWrErwr1r1r2�do_remote_user�s
zConsoleCLI.do_remote_usercCst�d�dS)Nz2Set the user for use as login to the remote targetrzrBr1r1r2�help_remote_user�szConsoleCLI.help_remote_usercCs2|r||_nt�d�t�d|j�|��dS)zFGiven a username, set the user that plays are run by when using becomez1Please specify a user, e.g. `become_user jenkins`zCurrent user is %sN)r#rErnrWrwr1r1r2�do_become_user�s

zConsoleCLI.do_become_usercCst�d�dS)NznSet the user for use with privilege escalation (which remote user attempts to 'become' when become is enabled)rzrBr1r1r2�help_become_user�szConsoleCLI.help_become_usercCs:|r||_t�d|j�nt�d�t�d|j�dS)zLGiven a become_method, set the privilege escalation method when using becomezbecome_method changed to %sz7Please specify a become_method, e.g. `become_method su`zCurrent become_method is %sN)r$rErnrwr1r1r2�do_become_method�s

zConsoleCLI.do_become_methodcCst�d�dS)NzASet the privilege escalation plugin to use when become is enabledrzrBr1r1r2�help_become_method�szConsoleCLI.help_become_methodcCsB|r$t|dd�|_t�d|j�nt�d�t�d|j�dS)z(Toggle whether plays run with check modeFr�zcheck mode changed to %sz1Please specify check mode value, e.g. `check yes`zcheck mode is currently %s.N)rr%rErnrwr1r1r2�do_check�s

zConsoleCLI.do_checkcCst�d�dS)NzToggle check_mode for the tasksrzrBr1r1r2�
help_check�szConsoleCLI.help_checkcCsB|r$t|dd�|_t�d|j�nt�d�t�d|j�dS)z"Toggle whether plays run with diffFr�zdiff mode changed to %sz-Please specify a diff value , e.g. `diff yes`zdiff mode is currently %sN)rr&rErnrwr1r1r2�do_diff�s

zConsoleCLI.do_diffcCst�d�dS)Nz Toggle diff output for the tasksrzrBr1r1r2�	help_diff�szConsoleCLI.help_diffc
Cst|rhz&t|�}|dkr"t�d�n||_Wqpttfyd}zt�dt|��WYd}~qpd}~00n|��dS)zSet the timeoutrz@The timeout must be greater than or equal to 1, use 0 to disablezAThe timeout must be a valid positive integer, or 0 to disable: %sN)r|rErdr(r}r�r�
usage_timeout)r-rxr_rtr1r1r2�
do_timeout�s
*zConsoleCLI.do_timeoutcCst�d�|��dS)NzSet task timeout in seconds)rEr�rBr1r1r2�help_timeout�s
zConsoleCLI.help_timeoutcCst�d�dS)NzUsage: timeout <seconds>rzrBr1r1r2r��szConsoleCLI.usage_timeoutcCstj�d�dS)zExits from the consolez
Ansible-console was exited.
���)�sys�stdout�writer,r1r1r2rM�szConsoleCLI.do_exitcCst�d�dS)NzLEAVE!rzrBr1r1r2�	help_exit�szConsoleCLI.help_exitcCs�|r�t�|�}|r�t�|t�\}}}}|r�t�|d�t�d�|d��D]2}t�dt||j�d|d|dd�qNq�t�	d|�nt�	d	|�dS)
NZshort_descriptionzParameters:rFz  r\�descriptionrzNo documentation found for %s.z<%s is not a valid command, use ? to list all valid commands.)
rrfr�
get_docstringrrE�keysrrUrd)r-�module_name�in_path�oc�a�_dummy1�_dummy2�optr1r1r2�helpdefault�s

2zConsoleCLI.helpdefaultcCst�d�dS)NzDon't be redundant!)rEZwarningrBr1r1r2�	help_help�szConsoleCLI.help_helpcsb|�d�d�t��t|��|jdvr6|j|j}ndd�|j�|j�D�}��fdd�|D�S)Nr\�)r4r�\cSsg|]
}|j�qSr1�ra��.0�xr1r1r2�
<listcomp>��z*ConsoleCLI.complete_cd.<locals>.<listcomp>cs.g|]&}t|��t���rt|��d��qSrG)r
rc�r��s�ZmlineZoffsr1r2r��r�)�	partitionrSr rrrPrQ�r-�textrpZbegidxZendidxZcompletionsr1r�r2�complete_cd�s
zConsoleCLI.complete_cdcs\|��d|��vrX|�d�d�t��t|��|�|��d�}��fdd�|D�SdS)Nrr\r�cs&g|]}|���r|�d�d�qS)N�=)rcr�r�r1r2r��r�z.ConsoleCLI.completedefault.<locals>.<listcomp>)rerYrSrqr�r1r�r2�completedefault�s
zConsoleCLI.completedefaultcCs2t�|�}tj|tdd�\}}}}t|d���S)NT)Z	is_modulerF)rrfrr�r�listr�)r-r�r�r�r�r�r�r1r1r2rqs
zConsoleCLI.module_argscs�tt����d}d}tjd�_�j�_tjd�_tjd�_tjd�_	tjd�_
tjd�_tjd�_tjd�_
tjd	�_tjd
r�tjd
D]}|r�t�|�q�����_�jD]<}t�d||f�fdd
�	�t�d||f�fdd
�	�qˆ��\}}||d��_���\�_�_�_���jtjd�j�}�j���_dd�|D��_dtjv�rxt� d�n
t� d�t!j"�#t!j"�$d�d�}zt�%|�Wnt&�y�Yn0t'�(tj)|���*���+�dS)Nrr!r"r#r$�checkr&r'r(Zmodule_path�do_cs��|d|�S�Nr\rv�rxrXrBr1r2�<lambda>$r�z ConsoleCLI.run.<locals>.<lambda>�help_cs
��|�SrG�r��rXrBr1r2r�%r�)Z	conn_passZbecome_passZsubsetcSsg|]
}|j�qSr1r�r�r1r1r2r�/r�z"ConsoleCLI.run.<locals>.<listcomp>�libeditzbind ^I rl_completez
tab: complete�~z.ansible-console_history),rrrkrZCLIARGSrr r!r"r#r$r%r&r'r(rZ
add_directoryrY�modules�setattrZ
ask_passwordsrZ
_play_prereqsrrPrZ
get_host_listZlist_groupsrr�readline�__doc__�parse_and_bind�os�pathrg�
expanduser�read_history_file�IOError�atexit�register�write_history_filerWrJ)r-ZsshpassZ
becomepassr�rXrZhistfiler/rBr2rksL



zConsoleCLI.runcs�d}|�d�rJ|�dd�}t�|�r�t�||f�fdd�	�t��|�}nD|�d�r�|�dd�}t�|�r�t�||f�fdd�	�t��|�}|dur�t�j�d|�d	���|S)
z[ handle not found to populate dynamically a module function if module matching name exists Nr�r]cs��|d|�Sr�rvr�rBr1r2r�Ir�z(ConsoleCLI.__getattr__.<locals>.<lambda>r�cs
��|�SrGr�r�rBr1r2r�Nr�z does not have a z
 attribute)	rc�replacerrfr��object�__getattr__�AttributeErrorr0)r-ra�attrrXr1rBr2r�Bs



zConsoleCLI.__getattr__)F)@�__name__�
__module__�__qualname__r�rar�Z	ARGUMENTSrTZCOLOR_CONSOLE_PROMPTZCOLOR_HIGHLIGHTrUrr>rCrIrJrWrYr8ruryr{rr�r~Z	do_serialZhelp_serialr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rMr�Zdo_EOFZhelp_EOFr�r�r�r�rqrkr��
__classcell__r1r1r/r2r&sr
X					<rcCst�|�dSrG)rZcli_executor)r.r1r1r2�mainWsr��__main__)N)0Z
__future__rrr�typeZ
__metaclass__Zansible.clirr�r*rOr�r�r�ZansiblerrTrZansible.cli.argumentsrr?Z#ansible.executor.task_queue_managerr	Zansible.module_utils._textr
rZ)ansible.module_utils.parsing.convert_boolrZansible.parsing.splitterr
Zansible.playbook.playrZansible.plugins.listrZansible.plugins.loaderrrZ
ansible.utilsrZansible.utils.colorrZansible.utils.displayrrEr+rr�r�r1r1r1r2�<module>s<5