# PlaybookExecutor - Python API 2.0

**URL:** <https://forum.ansible.com/t/playbookexecutor-python-api-2-0/27841>\
**Category:** Ansible Developer\
**Created:** [June 21, 2018, 9:50am UTC](https://forum.ansible.com/t/playbookexecutor-python-api-2-0/27841 "2018-06-21T09:50:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Suren\_Baskaran](https://avatars.discourse-cdn.com/v4/letter/s/3be4f8/32.png) [@Suren\_Baskaran](https://forum.ansible.com/u/Suren_Baskaran)\
**Post date:** [June 21, 2018, 9:50am UTC](https://forum.ansible.com/t/playbookexecutor-python-api-2-0/27841/1 "2018-06-21T09:50:24Z")

</div>

Hey Folks  
So while executing playbooks via the PlaybookExecutor API , I want to pass my custom callback derived from CallbackBase + also to get the log file written with an command line like output.

run\_pbook = PlaybookExecutor(  
playbooks=[playbook], inventory=inventory, loader=loader,  
variable\_manager=variable\_manager, options=options,  
passwords=passwords  
)  
callback = ResultCallback() -----\>My custom call back for API responses

run\_pbook.\_tqm.\_stdout\_callback = callback-----------------\> this accepts only one stdout call back

So I am wondering how would I achieve my use case of writing an command-line like output to log files

Things tried so far

1. when using PlaybookExecutor call , the log\_path in ansible.cfg does get written to.
2. I wanted to capture sys.stdout and sys.stderr to lo streaming- but though it captures warnings but not the actual TASK and Play output.

I would really appreciate some help on how I can achieve this .

Regards  
VB

---

<div class="post-metadata">

**Author:** ![Suren\_Baskaran](https://avatars.discourse-cdn.com/v4/letter/s/3be4f8/32.png) [@Suren\_Baskaran](https://forum.ansible.com/u/Suren_Baskaran)\
**Post date:** [June 21, 2018, 10:12am UTC](https://forum.ansible.com/t/playbookexecutor-python-api-2-0/27841/2 "2018-06-21T10:12:10Z")

</div>

\*\*\*Correction  
While executing via PlaybookExecutor log don’t get written to log defined in the ansible.cfg

Tried redirecting stdout and stderr as well - but I don’t get the Task and Play output

Thanks,  
Suren VB
