관리-도구
편집 파일: tree.cpython-39.pyc
a �����)g�����������������������@���sp���d�dl�mZmZmZ�eZdZd�dlZd�dlm Z �d�dl mZmZ�d�dl mZ�d�dlmZmZ�G�dd ��d e�ZdS�) �����)�absolute_import�division�print_functionaB�� name: tree type: notification requirements: - invoked in the command line short_description: Save host events to files version_added: "2.0" options: directory: version_added: '2.11' description: directory that will contain the per host JSON files. Also set by the C(--tree) option when using adhoc. ini: - section: callback_tree key: directory env: - name: ANSIBLE_CALLBACK_TREE_DIR default: "~/.ansible/tree" type: path description: - "This callback is used by the Ansible (adhoc) command line option C(-t|--tree)." - This produces a JSON dump of events in a directory, a file for each host, the directory used MUST be passed as a command line option. N)�TREE_DIR)�to_bytes�to_text)�CallbackBase)� makedirs_safe�unfrackpathc�����������������������s\���e�Zd�ZdZdZdZdZdZd��fdd� Zd d ��Z dd��Z d d��Zddd�Zdd��Z ���ZS�)�CallbackModulez] This callback puts results into a host specific file in a directory in json format. g�������@Z aggregate�treeTNc��������������������s6���t�t|��j|||d��tr&tt�|�_n|��d�|�_dS�)z override to set self.tree )� task_keys�var_options�directZ directoryN)�superr����set_optionsr���r ���r���Z get_option)�selfr ���r���r����� __class__���A/usr/lib/python3.9/site-packages/ansible/plugins/callback/tree.pyr���1���s����zCallbackModule.set_optionsc�������������� ���C���s����t�|�}zt|�j��W�nF�ttfy\�}�z*|�j�dt|�j�t|�f���W�Y�d}~n d}~0�0�zLt�tj � |�j|��}t|d��}|�|��W�d����n1�s�0����Y��W�n@�ttfy��}�z$|�j�d|t|�f���W�Y�d}~n d}~0�0�dS�)z' write something into treedir/hostname z<Unable to access or create the configured directory (%s): %sNzwb+z Unable to write to %s's file: %s) r���r ���r����OSError�IOErrorZ_displayZwarningr����os�path�join�open�write)r����hostname�buf�er����fdr���r���r����write_tree_file<���s����4,zCallbackModule.write_tree_filec�����������������C���s���|���|j���|��|j���d�S��N)r"���Z_hostZget_nameZ _dump_resultsZ_result�r����resultr���r���r����result_to_treeL���s����zCallbackModule.result_to_treec�����������������C���s���|���|��d�S�r#����r&���r$���r���r���r����v2_runner_on_okO���s����zCallbackModule.v2_runner_on_okFc�����������������C���s���|���|��d�S�r#���r'���)r���r%���� ignore_errorsr���r���r����v2_runner_on_failedR���s����z"CallbackModule.v2_runner_on_failedc�����������������C���s���|���|��d�S�r#���r'���r$���r���r���r����v2_runner_on_unreachableU���s����z'CallbackModule.v2_runner_on_unreachable)NNN)F)�__name__� __module__�__qualname__�__doc__ZCALLBACK_VERSIONZ CALLBACK_TYPEZ CALLBACK_NAMEZCALLBACK_NEEDS_ENABLEDr���r"���r&���r(���r*���r+���� __classcell__r���r���r���r���r���'���s��� r���)Z __future__r���r���r����typeZ __metaclass__Z DOCUMENTATIONr���Zansible.constantsr���Zansible.module_utils._textr���r���Zansible.plugins.callbackr���Zansible.utils.pathr ���r ���r���r���r���r���r����<module>���s���