관리-도구
편집 파일: pull.cpython-39.opt-1.pyc
a �)g�B � @ s d dl mZmZmZ eZd dlmZ d dlZd dl Z d dl Z d dlZd dlZd dl Z d dlZd dlZd dlZd dlmZ d dlmZ d dlmZ d dlmZ d dlmZmZ d d lmZ d d lm Z d dl!m"Z" e"� Z#G dd � d e�Z$ddd�Z%e&dk�r e%� dS )� )�absolute_import�division�print_function)�CLIN)� constants)�context)�option_helpers)�AnsibleOptionsError)� to_native�to_text)� module_loader)�run_cmd)�Displayc s� e Zd ZdZdZdZdZdZddd�Zd d iZ dZ edd � �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. zansible-pull�gitz local.yml)r � subversion�hg�bzrzFile does not existzFile is not readable)� � �playbook.ymla The 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*.Tc C sd d} t j�dd�r`t jd D ]B}t|t�r>| dd�|� 7 } qd|v sRtj�|�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_cliC s zPullCLI._get_inv_clic s� t t| �jddd� t�| j� t�| j� t�| j� t�| j� t� | j� t� | j� t�| j� | jjddddd� | jjd d ddd � | jjdddd ddd� | jjdddddd� | jjdddd ddd� | jjddddt� � d d!� | jjd"d#d$dd%d� | jjd&d'dd(d)� | jjd*d+d,d-d.� | jjd/d d0dd1d2� | jjd3d4d5| jd6| j| jf d� | jjd7d8d dd9d� | jjd:d;d dd<d� | jjd=d>d dd?d� | jjd@d dAddBd2� | jjdCtjdDddEd2� 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)r0 r- r) z-fz--force�forcez<run the playbook even if the repository could not be updatedz-dz--directoryr0 zDpath to the directory to which Ansible will checkout the repository.)r0 r- �typer) z-Uz--url�urlzURL of the playbook repositoryz--full� fullclonez*Do a full clone, instead of a shallow one.)r0 r. r) z-Cz --checkout�checkoutzIbranch/tag/commit to checkout. Defaults to behavior of repository module.)r0 r) z--accept-host-key�accept_host_keyz6adds the hostkey for the repo url if not already added)r- r0 r. 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_argumentZunfrack_path�DEFAULT_REPO_TYPE�REPO_CHOICES�CZDIFF_ALWAYS)�self�� __class__r# r$ r? O sj ������� �������zPullCLI.init_parserc s� t t| ��|�}|js2t�� }tj�t j d|�|_tj�|j�r\tj�|j�s\t d|j ��|jr�zt�dt|j��}||_W n ty� t d|j ��Y n0 |js�t d��|j| jvr�t d|jd�| j�f ��|jt_| �|� |S )NZpullz*%s is not a valid or accessible directory.r z%s is not a number.z1URL for repository not specified, use -h for helpz*Unsupported repo module %s, choices are %sr )r>