From c6b4b0569b134e996f907edb90cf489c5fa1efc9 Mon Sep 17 00:00:00 2001 From: dcore94 Date: Thu, 11 Feb 2021 15:39:52 +0100 Subject: [PATCH] added task name and set fatcs to output --- pyexecplugins/Ansible.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pyexecplugins/Ansible.py b/pyexecplugins/Ansible.py index eb1f9ec..31e0fe4 100644 --- a/pyexecplugins/Ansible.py +++ b/pyexecplugins/Ansible.py @@ -35,7 +35,9 @@ class ResultsCollectorJSONCallback(CallbackBase): def v2_runner_on_ok(self, result, *args, **kwargs): host = result._host - self.host_ok.append({ "host" :host.get_name(), "result" : result._result}) + #print(dir(result._task), result._result.get("ansible_facts")) + #self.host_ok.append({ "host" :host.get_name(), "result" : result._result}) + self.host_ok.append({ "host" :host.get_name(), "name" : result._task.name, "result" : { "stdout" : result._result.get("stdout"), "stderr" : result._result.get("stderr"), "ansible_facts" : result._result.get("ansible_facts") }}) def v2_runner_on_failed(self, result, *args, **kwargs): host = result._host @@ -92,7 +94,7 @@ class Ansible(PyExecPlugin): inventory = InventoryManager(loader=loader, sources=sources) # variable manager takes care of merging all the different sources to give you a unified view of variables available in each context - logging.getLogger("pyexec").debug("Instiantiating VarableManager %s %s", loader, inventory) + logging.getLogger("pyexec").debug("Instiantiating VariableManager %s %s", loader, inventory) try: variable_manager = VariableManager(loader=loader, inventory=inventory) except Exception as exc: