I have python script and have to call ansible playbook and tasks in various phases of script execution. What is preferred way to call ansible playbook or task?
You also have Ansible Runner that's created for this purpose
"A tool and python library that helps when interfacing with Ansible directly or as part of another system whether that be through a container image interface, as a standalone tool, or as a Python module that can be imported. The goal is to provide a stable and consistent interface abstraction to Ansible."
I prefer going python API way.Looks to me there can be stability issues with versions.
for now I will go with subprocess so that I dont have to end up resolving version conflicts down the line.