Thoughts on Ansible as an AP

I’ve been doing a bit of work with using Ansible as an API recently, and there are a few minor gaps.

For example I believe the on_ok and on_failed calls from _run_task could be passed the name of the task
The completion of a playbook has no associated callback.

It would also be nice to customize what Playbook.run() returns (perhaps a future on_complete could compile the results to return) - sure, stats.summarize might be what you want for some jobs, other times you might just want the concatenation of all the standard out, for example.

I guess my question for here is if I did some tidying in these areas such that ansible-playbook and ansible still work, and the tests all pass, would it be integrated at some point in future?

Will

Hi Will,

the API is designed to serve the needs of /usr/bin/ansible and /usr/bin/ansible-playbook, and it’s very important that we keep the API signatures of all the callback plugins operational.

I’m not positive the things you say are gaps - The task name, for instance, is already set on the callback object so it’s accessible.

If folks want to concatenate all the stdout (seems a bit arbitrary, but fine if you want), that sounds like a great place for a custom callback plugin.

For those that want a really sweet REST way to call into the system and introspect recorded (and running) job results, I’d also suggest looking at Ansible Tower. http://www.ansible.com/tower