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

�)g�B�@sddlmZmZmZeZddlmZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZddlZddlmZddlmZddlmZddlmZddlmZmZdd	lmZdd
lm Z ddl!m"Z"e"�Z#Gdd
�d
e�Z$ddd�Z%e&dk�re%�dS)�)�absolute_import�division�print_function)�CLIN)�	constants)�context)�option_helpers)�AnsibleOptionsError)�	to_native�to_text)�
module_loader)�run_cmd)�Displaycs�eZdZdZdZdZdZdZddd�Zd	d
iZ	dZ
edd
��Z�fdd�Z
�fdd�Z�fdd�Zedd��Zedd��Z�ZS)�PullCLIaO Used to pull a remote copy of ansible on each managed node,
        each set to run via cron and update playbook source via a source repository.
        This inverts the default *push* architecture of ansible into a *pull* architecture,
        which has near-limitless scaling potential.

        None of the CLI tools are designed to run concurrently with themselves,
        you should use an external scheduler and/or locking to ensure there are no clashing operations.

        The setup playbook can be tuned to change the cron frequency, logging locations, and parameters to ansible-pull.
        This is useful both for extreme scale-out as well as periodic remediation.
        Usage of the 'fetch' module to retrieve logs from ansible-pull runs would be an
        excellent way to gather and analyze remote logs from ansible-pull.
    zansible-pull�gitz	local.yml)r�
subversion�hg�bzrzFile does not existzFile is not readable)���playbook.ymlaThe name of one the YAML format files to run as an Ansible playbook.This can be a relative path within the checkout. By default, Ansible willlook for a playbook based on the host's fully-qualified domain name,on the host hostname and finally a playbook named *local.yml*.TcCsdd}tj�dd�r`tjdD]B}t|t�r>|dd�|�7}qd|vsRtj�|�r|d|7}q|S)N�Z	inventoryFz	 -i '%s' �,z -i %s )	r�CLIARGS�get�
isinstance�list�join�os�path�exists)�inv_opts�inv�r#�4/usr/lib/python3.9/site-packages/ansible/cli/pull.py�_get_inv_cliCs
zPullCLI._get_inv_clics�tt|�jddd�t�|j�t�|j�t�|j�t�|j�t�	|j�t�
|j�t�|j�|jjddddd�|jjd	d
ddd
�|jjdddd
ddd�|jjdddddd�|jjdddd
ddd�|jjddddt�
�d d!�|jjd"d#d$dd%d�|jjd&d'dd(d)�|jjd*d+d,d-d.�|jjd/d
d0dd1d2�|jjd3d4d5|jd6|j|jfd�|jjd7d8d
dd9d�|jjd:d;d
dd<d�|jjd=d>d
dd?d�|jjd@d
dAddBd2�|jjdCtjdDddEd2�dS)Fz* create an options parser for bin/ansible z0%prog -U <repository> [options] [<playbook.yml>]zDpulls playbooks from a VCS repo and executes them for the local host)�usageZdesc�argszPlaybook(s)r�*)�help�metavar�nargsz--purgeF�
store_truez!purge checkout after playbook run)�default�actionr)z-oz--only-if-changed�	ifchangedz8only run the playbook if the repository has been updated)�destr-r.r)z-sz--sleep�sleepNz|sleep for random interval (between 0 and n number of seconds) before starting. This is a useful way to disperse git requests)r0r-r)z-fz--force�forcez<run the playbook even if the repository could not be updatedz-dz--directoryr0zDpath to the directory to which Ansible will checkout the repository.)r0r-�typer)z-Uz--url�urlzURL of the playbook repositoryz--full�	fullclonez*Do a full clone, instead of a shallow one.)r0r.r)z-Cz
--checkout�checkoutzIbranch/tag/commit to checkout. Defaults to behavior of repository module.)r0r)z--accept-host-key�accept_host_keyz6adds the hostkey for the repo url if not already added)r-r0r.r)z-mz
--module-name�module_namezdRepository module name, which ansible will use to check out the repo. Choices are %s. Default is %s.z--verify-commit�verifyz�verify GPG signature of checked out commit, if it fails abort running the playbook. This needs the corresponding VCS module to support such an operationz--clean�cleanz:modified files in the working repository will be discardedz--track-subs�	tracksubsztsubmodules will track the latest changes. This is equivalent to specifying the --remote flag to git submodule updatez--check�checkzRdon't make any changes; instead, try to predict some of the changes that may occurz--diff�diffzhwhen changing (small) files and templates, show the differences in those files; works great with --check)�superr�init_parser�opt_helpZadd_connect_options�parserZadd_vault_optionsZadd_runtask_optionsZadd_subset_optionsZadd_inventory_optionsZadd_module_optionsZadd_runas_prompt_options�add_argumentZunfrack_path�DEFAULT_REPO_TYPE�REPO_CHOICES�CZDIFF_ALWAYS)�self��	__class__r#r$r?Osj
�������
�������zPullCLI.init_parsercs�tt|��|�}|js2t��}tj�t	j
d|�|_tj�|j�r\tj�|j�s\t
d|j��|jr�zt�dt|j��}||_Wn ty�t
d|j��Yn0|js�t
d��|j|jvr�t
d|jd�|j�f��|jt_|�|�|S)NZpullz*%s is not a valid or accessible directory.rz%s is not a number.z1URL for repository not specified, use -h for helpz*Unsupported repo module %s, choices are %sr)r>r�post_process_argsr0�socket�getfqdnrrrrEZANSIBLE_HOMEr �isdirr	r1�randomZrandint�int�
ValueErrorr4r8rD�	verbosity�displayZvalidate_conflicts)rF�options�hostnameZsecsrGr#r$rI�s&

zPullCLI.post_process_argsc
stt|���tj��}t�|�d��t�d�tj	��t
��}t�
�}d�t|||�d�d|�d�dg��}|r�d|}nd}d}tjd	dkr�|d
d�dd
�tdtjd	�D��7}|��}|s�d}|dt�dtj�7}tjddk�r�dtjdtjdf}tjd�r.|dtjd7}tjd�rB|d7}tjd�r`|dtjd7}tjd�rt|d7}tjd�r�|d7}tjd �s�|d!7}�n
tjdd"k�r�d#tjdtjdf}tjd�r�|d$tjd7}tjd �s�|d%7}n�tjdd&k�rDd#tjdtjdf}tjd�r�|d$tjd7}nftjdd'k�r�dtjdtjdf}tjd�r�|dtjd7}ntd(tjdd�|j�f��tjd)�r�|d*7}t�tjd�}	|	d+u�r�td,tjd��tj�tj�tj	d��}
d-|
||tjd||f}tjd.D]}|d/t�|�7}�q(tjd0�rrt�d1tjd0�t� tjd0�t�!d2�t�"d3|�t#|d4d5�\}
}}|
dk�r�tjd6�r�t�$d7�n|
Sn$tjd8�r�d9|v�r�t�d:�dS|�%tjd�}|d+u�r
td;��d<|
||f}tjd=�rBtjd=D]}|d>|7}�q.tjd?�rltjd?D]}|d@|7}�qXtjd.D]}|d/t�|�7}�qvtjdA�r�|dB7}tjdC�r�|dDt&d�tjdC��7}tjdE�r�|dFt&d�tjdE��7}tjdG�r|dHtjdG7}n|dH|7}tjdI�r4|dJ7}tjdK�rH|dL7}t�'tjd�|��}|�rn||7}t�!dM�t�!d3|�t#|d4d5�\}
}}tjdN�rt�'dO�z(t�!dPtjd�t(�)tjd�WnBt*�y}z(t�+dQtjdt,|�f�WYd+}~n
d+}~00|
S)Rz! use Runner lib to do SSH things zStarting Ansible Pull at %F %T� r�.rzlocalhost,%s,127.0.0.1zlocalhost,127.0.0.1z	-c local rPz -%srcSsg|]}d�qS)�vr#)�.0�xr#r#r$�
<listcomp>��zPullCLI.run.<locals>.<listcomp>z -i localhost, z-e %s zansible_python_interpreter=%sr8rzname=%s dest=%sr4r0r6z version=%sr7z accept_hostkey=yesZprivate_key_filez key_file=%sr9z verify_commit=yesr;z track_submodules=yesr5z depth=1rzrepo=%s dest=%sz revision=%sz export=yesrrz5Unsupported (%s) SCM module for pull, choices are: %sr:z
 force=yesNzmodule '%s' not found.
z*%s/ansible %s %s -m %s -a "%s" all -l "%s"Z
extra_varsz -e %sr1zSleeping for %d seconds...z0running ansible with VCS module to checkout repozEXEC: %sT)Zliver2zFUnable to update repository. Continuing with (forced) run of playbook.r/s"changed": truez%Repository has not changed, quitting.z!Could not find a playbook to run.z%s/ansible-playbook %s %sZvault_password_filesz --vault-password-file=%sZ	vault_idsz --vault-id=%sZbecome_ask_passz --ask-become-passZ	skip_tagsz --skip-tags "%s"�tagsz -t "%s"Zsubsetz -l "%s"r<z -Cr=z -Dz*running ansible-playbook to do actual work�purge�/zremoving: %szFailed to remove %s: %s)-r>r�run�datetime�nowrQ�strftimer�sys�argv�platform�noderJrK�set�splitrr�ranger%�shlex�quote�
executabler	rDrZfind_pluginrr�dirname�abspath�timer1�debugZvvvvr
�warning�select_playbookr
�chdir�shutil�rmtree�	Exception�errorr)rFr`re�hostZ	hostnamesZ
limit_optsZ	base_optsr!Z	repo_optsrZbin_path�cmdZev�rcZb_outZb_err�playbookZvault_password_fileZvault_id�erGr#r$r^�s�
*
(

��
�





2zPullCLI.runcCs&tj�|�sdSt�|tj�s"dSdS)Nrrr)rrr �access�R_OK)rr#r#r$�try_playbook=s
zPullCLI.try_playbookcCspd}g}tjdr�tjdddur�g}tjdD]H}tj�||�}t�|�}|dkrp|�d|tj|f�q2|�|�q2dt	|�kr�t
�d�|��n t	|�t	tjd�kr�d�|�}|St�
�}tj�||d�}tj�||�d�dd�}	tj�|tj�}
||	|
fD]>}t�|�}|dk�r2|}�qNn|�d|tj|f��q|du�rht
�d�|��|SdS)Nr'rz%s: %s�
rTz.ymlrU)rrrrrrr~�append�PLAYBOOK_ERRORS�lenrQrprJrKrg�DEFAULT_PLAYBOOK)rrz�errorsZ	playbooksZbookZ	book_pathryZfqdnZhostpbZshorthostpbZlocalpbZpbr#r#r$rqEs:




zPullCLI.select_playbook)�__name__�
__module__�__qualname__�__doc__�namerCr�rDr�Z	ARGUMENTSZSKIP_INVENTORY_DEFAULTS�staticmethodr%r?rIr^r~rq�
__classcell__r#r#rGr$r$s(�
4
rcCst�|�dS)N)rZcli_executor)r'r#r#r$�mainhsr��__main__)N)'Z
__future__rrrr3Z
__metaclass__Zansible.clirr_rrdrMrirsrJrbrnZansiblerrErZansible.cli.argumentsrr@Zansible.errorsr	Zansible.module_utils._textr
rZansible.plugins.loaderrZansible.utils.cmd_functionsr
Zansible.utils.displayrrQrr�r�r#r#r#r$�<module>s4F