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__/config.cpython-39.pyc
a

�)g�V�@s\ddlmZmZmZeZddlmZddlZddl	Z	ddl
Z
ddlZddlm
Z
ddlmZddlmmZddlmZddlmZddlmZmZdd	lmZmZdd
lm Z m!Z!m"Z"ddl#m$Z$ddl%m&Z&dd
l'm(Z(ddl)m*Z*ddl+m,Z,ddl-m.Z.ddl/m0Z0e.�Z1ddd�Z2dd�Z3dd�Z4Gdd�de�Z5ddd�Z6e7dk�rXe6�dS) �)�absolute_import�division�print_function)�CLIN)�Mapping)�context)�	constants)�option_helpers)�
ConfigManager�Setting)�AnsibleError�AnsibleOptionsError)�	to_native�to_text�to_bytes)�	json_dump)�string_types)�	is_quoted)�
AnsibleDumper)�stringc)�Display)�unfrackpathFcCstj|t||d�S)N)ZDumper�default_flow_style�
default_style)�yaml�dumpr)�datarr�r�6/usr/lib/python3.9/site-packages/ansible/cli/config.py�	yaml_dump&srcCst|ddd�S)NTz'')rr)r)rrrr�
yaml_short*sr cCs$ttd�sdd�tt�D�t_tjS)zE helper method to ensure we can template based on existing constants �cvarscSs"i|]}|�d�s|tt|��qS)�__)�
startswith�getattr�C)�.0�krrr�
<dictcomp>1�z!get_constants.<locals>.<dictcomp>)�hasattr�
get_constants�dirr%r!rrrrr+.s
r+cs�eZdZdZdZd&�fdd�	Z�fdd�Z�fdd	�Z�fd
d�Zdd
�Z	dd�Z
dd�Zd'dd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Z�ZS)(�	ConfigCLIz Config command line class zansible-configNcs"d|_d|_tt|��||�dS�N)�config_file�config�superr-�__init__)�self�args�callback��	__class__rrr2:szConfigCLI.__init__c	s�tt|�jdd�tjjdd�}t�|�|jddddd	�|jd
ddd
ddd
gtt	j
�dd�|jdddd�|jjdd�}d|_
|jdd|gd�}|j|jd�|jddddd d!gd!d"d#�|jd$d%|gd�}|j|jd�|jd&d'd(d)d*d+�|jddddgd,�d-d.d#�|jd/d0|gd�}|j|jd�|jd1d2|gd�}|j|jd�|jddddgd3�d4d5d#�|jd6d7d)dd8d9�dS):NzView ansible configuration.)�descF)�add_help�-cz--configr/zGpath to configuration file, defaults to first file found in precedence.)�dest�helpz-tz--type�store�base�type�allz&Filter down to a specific plugin type.)�action�defaultr;�choicesr<r4z<Specific plugin to target, requires type of plugin to be set�*)r<�nargsrA)r;T�listzPrint all config options)r<�parents)�funcz--formatz-f�format�jsonrzOutput format for list)r;rArCrBr<rzDump configurationz--only-changedz--changed-only�only_changed�
store_truez;Only show configurations that have changed from the default)r;rAr<)rJr�displayrMzOutput format for dump�viewzView configuration file�init�Create initial configuration)�ini�env�varsrQzOutput format for initz
--disabled�	commentedz=Prefixes all entries with a comment character to disable them)r;rArBr<)r1r-�init_parser�opt_help�argparse�ArgumentParserZadd_verbosity_options�add_argumentrFr%�CONFIGURABLE_PLUGINS�parser�add_subparsers�required�
add_parser�set_defaults�execute_list�execute_dump�execute_view�execute_init)r3�commonZ
subparsersZlist_parserZdump_parserZview_parserrUr6rrrU@sJ
�

�������zConfigCLI.init_parsercstt|��|�}|jt_|Sr.)r1r-�post_process_args�	verbosityrM)r3�optionsr6rrrekszConfigCLI.post_process_argscsLtt|���tjdrrttjddd�|_t|j�}tj	�
|�r^t�|tj�r^t
|j�|_q�tdt|j���ntj|_|jj|_|j�r$zNtj	�
|j�s�td|j��ntj	�|j�s�td|j��t|j�tjd<WnFt�y tjdd	vr��n tjdd
v�rt�d|j�Yn0ntjddk�r<td
��tjd�dS)Nr/F)�followz@The provided configuration file is missing or not accessible: %sz&%s does not exist or is not accessiblez%s is not a valid fileZANSIBLE_CONFIGrA)rN)Zedit�updatez(File does not exist, used empty file: %srNz&Invalid or no config file was suppliedrH)r1r-�runr�CLIARGSrr/r�os�path�exists�access�R_OKr
r0r
rr%Z_config_file�isfile�environ�	ExceptionrM�warningr)r3Zb_configr6rrrjqs0


z
ConfigCLI.runcCs~td��tjddurtd��tjd�d�\}}d|vrJ|�d�\}}nd}|}t�dd	d
ddd
dd|j|||fg�dS)zG
        Updates a single setting in the specified ansible.cfg
        �Option not implemented yet�settingNz*update option requires a setting to update�=�.�defaults�ansiblez-mZini_fileZ	localhostr:�localz-az2"dest=%s section=%s option=%s value=%s backup=yes")rrrkr
�split�
subprocess�callr/)r3�entry�value�section�optionrrr�execute_update�s�zConfigCLI.execute_updatec
Cs�zFt|jd��&}|�t|��dd��Wd�n1s:0YWn4tyz}ztdt|���WYd}~n
d}~00dS)z2
        Displays the current config file
        �rb�surrogate_or_strict��errorsNzFailed to open config file: %s)�openr/�pagerr�readrsrr)r3�f�errrrb�s
8zConfigCLI.execute_viewcCsptd��z.t�tj�dd��}|�|j�t�	|�Wn4t
yj}ztdt|���WYd}~n
d}~00dS)z9
        Opens ansible.cfg in the default EDITOR
        ruZEDITOR�vizFailed to open editor: %sN)r�shlexr|rlrr�get�appendr/r}r~rsr)r3Zeditorr�rrr�execute_edit�szConfigCLI.execute_editc
Cs�i}ttd|�}|rVg}|D]4}|j|dd�}|durHt�d|�q|�|�qn|jdd�}|D]N}|j}}	|	�d�r�t	j
�|j�r�qfn|	�
ddd�d}|j�||	�||<qf|S)	N�	%s_loaderT�Z
class_only�0Skipping %s as we could not find matching plugin�_���
 (DEPRECATED))r$�
plugin_loaderr�rMrtr�r@�
_load_namer#rlrm�islink�_original_path�replacer0�get_configuration_definitions)
r3�ptype�plugins�entries�loader�	plugin_cs�plugin�p�	finalname�namerrr�_list_plugin_settings�s$

zConfigCLI._list_plugin_settingscCs�i}tjddvr |jjdd�}tjddkr6i|d<tjddkrhtjD]}|�|�|d|��<qJn4tjddkr�|�tjdtjd�|dtjd<|S)	z>
        build a dict with the list requested configs
        r?)r>r@T�Zignore_privater>�PLUGINSr@r4)rrkr0r�r%rZr��upper)r3�config_entriesr�rrr�_list_entries_from_args�s
&z!ConfigCLI._list_entries_from_argscCsL|��}tjddkr t|�}ntjddkr6t|�}|�t|dd��dS)z3
        list and output available configs
        rIrrJr�r�N)r�rrkrrr�r)r3r��outputrrrr`�s
zConfigCLI.execute_listcCs�g}tjdrd}nd}|D�]�}||�d�s2q||�dd�}|dkr�||�dd�}|dkrr|rld	}q�d
}n�|r�|dkr�t|t�s�zd�|�}Wn0ty�}zd
t|�}WYd}~n
d}~00t|t�r�t|�s�t	�
|�}n|dur�d}|||vr|||r|||dd}	t||dt��r@||d}
nd�||d�}
||�d|�}|�d|||�dd�|
f�|dk�r�|	�d��r�q|�d||	|f�n:|dk�r�|	�d��r�q|�|d|	t
t|�dd�f�|�d�q|S)NrT�#r��descriptionrBrRr?Zboolean�1�0rF�, z%s���r�z
#z# %s(%s): %s�stringZ	_ANSIBLE_z%s%s=%srSZ	_ansible_z%s: %sr�r�)rrkr��
isinstancer�joinrsrrr��quoter�r#rr )r3�settingsZsubkeyr�prefixrvrB�styper�rr8r�rrr�_get_settings_varssT


" 

"zConfigCLI._get_settings_varscCs|i}t|���D�]d}||}t|t�s*q|�d�sr|�|�}|D],}||vrb||�||�qB||||<qBqt|dt�r�d|�dd�|df}n"d|�dd�}|d�|d�7}d|vr|dr|dd}|d	|vr�g||d	<|�d
d�}	|�dd�dk�r&t|	t��s&d
�|	�}	n|	du�r4d}	t	j
d�rPd|d|d<|d|d|	f}
||d	�|
�q|S)Nr�z	# (%s) %sr?r�z# (%s) z
# rQr�r�rBr�rFr�rTz;%s�keyz
%s=%s)�sorted�keysr�rr��_get_settings_ini�extendrr�rrkr�)r3r��sections�o�optZnew_sections�sr8rrBr�rrrr�=s<



zConfigCLI._get_settings_inic	CsNg}|��}|�dd�}tjddkr�|�|�}|r~|D]D}|�||�}|D],}||vrn||�||�qN||||<qNq8|r�|��D]>}|�d|�||D]}	|�|	�|�d�q�|�d�q�nftjddv�r2|�|tjd�}|�r2|D]8}||��D]&}
|�|�|||
tjd���qq�|�	t
d�|�d	d
��dS)rPr�NrIrQz[%s]r�)rRrS�
r�r�)r��poprrkr�r�r�r�r�r�rr�)r3rr�Zplugin_typesr�r�Zplugin_sectionsr�r�r�r�rrrrcls4

&zConfigCLI.execute_initc	Cs�g}t|�D]�}||jdv}tjddkr�t||t�r�||jdkrNd}n||jdkrbd}nd}d	|||j||jf}nd}d	|d||�d�f}t||�}n&i}||j	D]}t
|||�||<q�tjd
r�|r|�|�q|S)N)rB�REQUIREDrIrMrBZgreenr�ZredZyellowz%s(%s) = %srK)r��originrrkr�rr�r�r�_fieldsr$r�)	r3r0r�rvZchangedZcolor�msgrr�rrr�_render_settings�s(zConfigCLI._render_settingscCsV|jjdd���}|��D]0}tjj||jt�d�\}}t|||d�||<q|�	|�S)NTr�)�cfile�	variables)
r0r��copyr�r%�get_config_value_and_originr/r+rr�)r3r0rv�vr�rrr�_get_global_configs�s
zConfigCLI._get_global_configscCs&ttd|�}g}i}|rdg}|D]>}|j|dd�}|durLt�d|�q"|�|j|dd��q"n|jdd�}|D�]�}|j}	}
|
�d�r�t	j
�|j�r�qt|
�
ddd�d}	|j�||
�||	<z|j|
dd�}WnJt�y}z0t�d	|
|t|�f�WYd}~qtWYd}~n
d}~00||	��D]�}
z"tjj|
|j||
t�d
�\}}WnDt�y�}z*t|��d��r~d}d}n|�WYd}~n
d}~00|du�r�|du�r�d}t|
||d�||	|
<�q,|�||	�}|rttjd
dk�r|�d|	dt|	�f�|�|�qt|�|	|i�qt|S)Nr�Tr�r�r�r�r�r�zMSkipping "%s" %s plugin, as we cannot load plugin to check config due to : %s)r�Zplugin_typeZplugin_namer�z2No setting was provided for required configurationr�rIrM�
%s:
%s)r$r�r�rMrtr�r@r�r#rlrmr�r�r�r0r�rsrr�r%r�r/r+rrrr�rrk�lenr�)r3r�r�r�r�r�r�r�r�r�r�rr�rvr�r��resultsrrr�_get_plugin_configs�sR


""zConfigCLI._get_plugin_configscCs8tjddkr|��}n�tjddkr�|��}tjD]�}|�|tjd�}tjddkr�tjdrf|r�|�d|��d	t|�f�|�	|�q4|d
vr�|��}nd|��}|�||i�q4n|�tjdtjd�}tjddkr�d�
|�}tjdd
k�r
t|�}ntjddk�r"t|�}|�
t|dd��dS)zM
        Shows the current settings, merges ansible.cfg if specified
        r?r>r@r4rIrMrKr�rw)�modulesZ
doc_fragmentsz
%s_PLUGINSr�rrJr�r�N)rrkr�r%rZr�r�r�r�r�r�rrr�r)r3r�r�Zplugin_listZpname�textrrrra�s,




zConfigCLI.execute_dump)N)N)�__name__�
__module__�__qualname__�__doc__r�r2rUrerjr�rbr�r�r�r`r�r�rcr�r�r�ra�
__classcell__rrr6rr-5s&+#


9/$ Fr-cCst�|�dSr.)r-Zcli_executor)r4rrr�main#sr��__main__)FN)N)8Z
__future__rrrr?Z
__metaclass__Zansible.clirrlrr�r}�collections.abcrrzrZansible.plugins.loaderr�r�r�rr%Zansible.cli.argumentsr	rVZansible.config.managerr
rZansible.errorsrr
Zansible.module_utils._textrrrZ ansible.module_utils.common.jsonrZansible.module_utils.sixrZansible.parsing.quotingrZansible.parsing.yaml.dumperrZansible.utils.colorrZansible.utils.displayrZansible.utils.pathrrMrr r+r-r�r�rrrr�<module>s@
q