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.

Thanks for sharing your experience.

On Wednesday, May 22, 2019 at 5:10:27 AM UTC-4, Kai Stian Olstad wrote:
>
> On 22.05.2019 08:11, Sudheer Satyanarayana wrote: 
> > On 22/05/19 7:05 AM, Yz Xyz wrote: 
> >> 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? 
> >> 
> >> I see python API was suggested to use for internal purpose only. 
> >> 
> https://docs.ansible.com/ansible/latest/dev_guide/developing_api.html#python-api-example
>  
> >> 
> >> The other way is to use subprocess. Want to know if subprocess can be 
> >> used reliably ? 
> >> 
> > I too want to use the Python API.  Since Ansible does not guarantee 
> > Python API compatibility with older versions, this can become a moving 
> > target. 
> > 
> > I have been using subprocess to execute Ansible playbooks. Of course 
> > it works reliably like executing any other command. Ansible is no 
> > different. 
>
> 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." 
>
> https://github.com/ansible/ansible-runner 
>
>
> -- 
> Kai Stian Olstad 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/29bee358-6df8-4a7d-8db5-9a58dd6be202%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to