Coverage for lib/ansible/plugins/callback/tree.py : 46%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
# (c) 2012-2014, Ansible, Inc # (c) 2017 Ansible Project # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
callback: tree callback_type: notification requirements: - invoked in the command line short_description: Save host events to files version_added: "2.0" description: - "This callback is used by the Ansible (adhoc) command line option `-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 commadn line option. '''
''' This callback puts results into a host specific file in a directory in json format. '''
super(CallbackModule, self).__init__()
self.tree = TREE_DIR if not self.tree: self.tree = os.path.expanduser("~/.ansible/tree") self._display.warning("The tree callback is defaulting to ~/.ansible/tree, as an invalid directory was provided: %s" % self.tree)
''' write something into treedir/hostname '''
buf = to_bytes(buf) try: makedirs_safe(self.tree) path = os.path.join(self.tree, hostname) with open(path, 'wb+') as fd: fd.write(buf) except (OSError, IOError) as e: self._display.warning("Unable to write to %s's file: %s" % (hostname, str(e)))
if self.tree: self.write_tree_file(result._host.get_name(), self._dump_results(result._result))
self.result_to_tree(result)
self.result_to_tree(result)
self.result_to_tree(result) |