Tweaking Ansible output

Ansible is indeed directly callable from your own python script. The Ansible API is fully documented. I have not used it myself but you should be able to write your own python script to leverage Ansible and do what you want. According to their documentation is as simple as this:

import ansible.runner

runner = ansible.runner.Runner(
   module_name='ping',
   module_args='',
   pattern='web*',
   forks=10
)
datastructure = runner.run()

There's a more thorough example in the documentation that I linked to.