Server IP : 80.87.202.40 / Your IP : 216.73.216.169 Web Server : Apache System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64 User : bitrix ( 600) PHP Version : 8.2.27 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /lib/python3.11/site-packages/ansible/cli/__pycache__/ |
Upload File : |
� ���c�U � �f � d dl mZmZmZ eZd dlmZ d dlZd dl Z d dl Z d dlZd dlZd dl Z d dlmZ d dlmZ d dlmZ d dlmZ d dlmZmZ d d lmZ d d lmZ d dlmZ d dl m!Z! d d l"m#Z#m$Z$ d dl%m&Z& d dl'm(Z( d dl)m*Z* e*� � Z+ G d� dee j, � � Z-dd�Z.e/dk r e.� � dS 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)�Displayc � � � e Zd ZdZdZg ZddiZej pej Z � fd�Z� fd�Z� fd�Z d� Zd � Zd � Zd� Zd6d �Zd� Zd� Zd� Zd� Zd� Zd� ZeZeZd� Zd� Zd� Zd� Zd� Zd� Z d� Z!d� Z"d� Z#d� Z$d� Z%d� Z&d � Z'd!� Z(d"� Z)d#� Z*d$� Z+d%� Z,d&� Z-d'� Z.d(� Z/d)� Z0d*� Z1d+� Z2d,� Z3d-� Z4d.� Z5e4Z6e5Z7d/� Z8d0� Z9d1� Z:d2� Z;d3� Z<� fd4�Z=d5� Z>� xZ?S )7� 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-consolezhost-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.c � �� t t | � � � |� � d| _ g | _ g | _ d | _ d | _ d | _ t � � | _ d| _ d | _ d | _ d | _ d | _ d | _ d | _ d | _ d | _ d | _ t* j � | � � d S )NzAWelcome to the ansible console. Type help or ? to list commands. �*)�superr �__init__�intro�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__s ��8/usr/lib/python3.11/site-packages/ansible/cli/console.pyr zConsoleCLI.__init__H s� �� � �j�$���(�(��.�.�.�Y�� ������ ���� $�������������� ���������!�������� ��� � ���������������� c �� �� t t | � � � dd�� � t j | j � � t j | j � � t j | j � � t j | j � � t j | j � � t j | j � � t j | j � � t j | j � � t j | j � � t j | j � � | j � ddddd�� � | j � d d dd� � � d S )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.)�desc�epilogr zhost pattern�all�?)�help�metavar�default�nargsz--step�step� store_truez4one-step-at-a-time: confirm each task before running)�dest�actionr: )r r �init_parser�opt_help�add_runas_options�parser�add_inventory_options�add_connect_options�add_check_options�add_vault_options�add_fork_options�add_module_options�add_basedir_options�add_runtask_options�add_tasknoplay_options�add_argument)r0 r2 s �r3 rB zConsoleCLI.init_parserd sL �� � �j�$���+�+�<�|� ,� � � � �"�4�;�/�/�/��&�t�{�3�3�3��$�T�[�1�1�1��"�4�;�/�/�/��"�4�;�/�/�/��!�$�+�.�.�.��#�D�K�0�0�0��$�T�[�1�1�1��$�T�[�1�1�1��'���4�4�4� �� � ����\a�il� �m�m�m��� � ���|�&\� !� ^� ^� ^� ^� ^r4 c � �� t t | � � � |� � }|j t _ | � |dd�� � |S )NT)� runas_opts� fork_opts)r r �post_process_args� verbosity�display�validate_conflicts)r0 �optionsr2 s �r3 rS zConsoleCLI.post_process_argsy sK �� �� �D�)�)�;�;�G�D�D��#�-�������D�D��I�I�I��r4 c � � t | � � S �N)�dir�r0 s r3 � get_nameszConsoleCLI.get_names s � ��4�y�y�r4 c � � t j � | � � d S # t $ r | � � � Y d S t $ r. | � d� � | � | � � Y d S w xY w)Nz[Ansible-console was exited])r. r/ �cmdloop�KeyboardInterrupt�EOFErrorrU �do_exitr[ s r3 r^ zConsoleCLI.cmdloop� s� � � ��G�O�O�D�!�!�!�!�!�� � � � ��L�L�N�N�N�N�N�N�� � � ��L�L�7�8�8�8��L�L�������� ���s �# �A;�3A;�:A;c �V � | j pt j � � }| j � | j � � | _ d|| j t | j � � | j fz }| j r| j dv r|dz }t j }n|dz }| j }t ||d�� � | _ d S )Nz%s@%s (%d)[f:%s])N�rootz# z$ T)�wrap_nonvisible_chars)r% �getpass�getuser� inventory� list_hostsr$ �selected�lenr+ r&