I'm trying to grasp callbacks with an example: I'd like to gather the
output of the setup module invoked by a Playbook. I've created a copy
of noop.py...
class CallbackModule(object):
def runner_on_ok(self, host, res):
print ">>>>>>>>>>> dump"
if res.get("verbose_override", None) is not None:
fname = "/tmp/a.%s" % host
print "++---- dumping to %s" % fname
f = open(fname, 'w')
f.write(json.dumps(res))
f.close()
1. I note that _on_setup is invoked just before a playbook gathers facts.
2. I see runner_on_ok is invoked AFTER setup has gathered the facts, but
it isn't passed the name of the task; all successfully completed
tasks end up here. Is there any way to find the name of the task?
I'm trying to grasp callbacks with an example: I'd like to gather the
output of the setup module invoked by a Playbook. I've created a copy
of noop.py...
class CallbackModule(object):
def runner_on_ok(self, host, res):
print ">>>>>>>>>>> dump"
if res.get("verbose_override", None) is not None:
fname = "/tmp/a.%s" % host
print "++---- dumping to %s" % fname
f = open(fname, 'w')
f.write(json.dumps(res))
f.close()
1. I note that _on_setup is invoked just before a playbook gathers facts.
2. I see runner_on_ok is invoked AFTER setup has gathered the facts, but
it isn't passed the name of the task; all successfully completed
tasks end up here. Is there any way to find the name of the task?
Yes. You should see the 'invocation' parameters in the JSON that
indicate what the module and parameters were.
These are hidden from regular /usr/bin/ansible-playbook output, but
available to API callers.