PlaybookExecutor example

Hello,

I'm trying to figure out how to use PlaybookExecutor. In short, I'd like
to run my playbook from the Python code using Ansible 2. I tried poking
the code but I'm just not smart enough, so a code snippet would be more
than welcome. Thank you!

Regards,
meka

I’d start with looking at how ansible uses it:

https://github.com/ansible/ansible/blob/c489b271d152820ab11b73d11877f8805318cd7a/lib/ansible/cli/playbook.py#L147-L150

From there, you should be able to look at how the vars it requires are constructed from further above in the code.

As far as self.options is concerned, there is a good approach listed at http://docs.ansible.com/ansible/developing_api.html#python-api-2-0

This really helps. Thank you A LOT!!!

As Ansible uses multiprocess for forking, it's imposible to use with
Celery. Is there any other recommendation for running playbooks? Or,
maybe, does anyone knows how Tower did it? Thank you!

IIRC Tower uses Celery also, they just execute the ansible-playbook CLI

For now, I'm using os.system but if anyone has any idea how to run
playbook programmaticaly, I'd be glad to hear it. Anyway, thank you very
much for your help!

Example: http://docs.ansible.com/ansible/developing_api.html , just a
reminder that it is GPL code and that doing it this way has
implications for distribution and/or services to 3rd parties.