Returning a value from my playbook to the python client

Hi All,
I am using the python api to call the playbook. Something like this

pb = ansible.playbook.PlayBook(
playbook=playbook,
remote_pass=sshpass,
callbacks=playbook_cb,
runner_callbacks=runner_cb,
stats=stats,
sudo_pass=sudopass,
extra_vars=extra_vars,
su_pass=su_pass,
vault_password=vault_pass,
private_key_file=private_key_file,
)

Problem is i need to return a value from one of my tasks to this calling code (client) Is there any elegant way of doing it(other than dumping value in temporary file or setting it in environment variable) ?

Regards
Ritesh

It seems you could use the functions exit_json / fail_json in your
module to return additional data in JSON format.

https://github.com/ansible/ansible/blob/devel/lib/ansible/module_utils/basic.py
http://docs.ansible.com/developing_modules.html#common-module-boilerplate

Have you considered developing a plugin and hooking into events you want
to handle?

Giovanni

ps.: I'm an Ansible newbie. Be warned.

Thanks Giovanni , i have implemented the callback plugins. I am also using the module.exit_json , but didnt realize this can be used to send back the data. I have now trapped the runner_on_ok and get the return value. Thanks for the info it worked