Dashboard
PHP:
8.2.30
OS:
Linux
User:
dh_nv8b2m
/
/
usr
/
local
/
lib
/
python3.10
/
dist-packages
/
ansible
/
plugins
/
callback
/
__pycache__
📤 Upload
📝 New File
📁 New Folder
Close
Editing: tree.cpython-310.pyc
o O�h� � @ sd d dl mZ dZd dlZd dlmZ d dlmZmZ d dl m Z d dlmZm Z G dd � d e �ZdS ) � )�annotationsaB 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 @� aggregate�treeTNc s8 t t| �j|||d� trtt�| _dS | �d�| _dS )z override to set self.tree )� task_keys�var_options�direct� directoryN)�superr �set_optionsr r r � get_option)�selfr r r �� __class__� �H/usr/local/lib/python3.10/dist-packages/ansible/plugins/callback/tree.pyr 0 s zCallbackModule.set_optionsc C s� t |�}zt| j� W n# ttfy. } z| j�dt| j�t|�f � W Y d}~nd}~ww z)t tj � | j|��}t|d��}|�|� W d � W dS 1 sQw Y W dS ttfyy } z| j�d|t|�f � W Y d}~dS d}~ww )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�IOError�_display�warningr �os�path�join�open�write)r �hostname�buf�er �fdr r r �write_tree_file; s *��&�&��zCallbackModule.write_tree_filec C s | � |j�� | �|j�� d S �N)r% �_host�get_name� _dump_results�_result�r �resultr r r �result_to_treeK s zCallbackModule.result_to_treec C � | � |� d S r&