o nnh @sdddlmZdZddlZddlmZddlmZmZddl m Z ddl m Z m Z Gdd 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_bytesto_text) CallbackBase) makedirs_safe unfrackpathcs\eZdZdZdZdZdZdZdfdd Zd d Z d d Z d dZ dddZ ddZ ZS)CallbackModulez] This callback puts results into a host specific file in a directory in json format. g@ aggregatetreeTNcs8tt|j|||dtrtt|_dS|d|_dS)z override to set self.tree ) task_keys var_optionsdirect directoryN)superr set_optionsrrr get_option)selfr r r __class__H/usr/local/lib/python3.10/dist-packages/ansible/plugins/callback/tree.pyr0szCallbackModule.set_optionsc Cst|}zt|jWn#ttfy.}z|jdt|jt|fWYd}~nd}~wwz)ttj |j|}t |d}| |WdWdS1sQwYWdSttfyy}z|jd|t|fWYd}~dSd}~ww)z' write something into treedir/hostname zs