# Toggle verbosity when running playbooks through the Ansible playbook API.

**URL:** <https://forum.ansible.com/t/toggle-verbosity-when-running-playbooks-through-the-ansible-playbook-api/18189>\
**Category:** Ansible Project\
**Created:** [May 8, 2015, 1:02pm UTC](https://forum.ansible.com/t/toggle-verbosity-when-running-playbooks-through-the-ansible-playbook-api/18189 "2015-05-08T13:02:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ayaz\_Ahmed\_Khan](https://avatars.discourse-cdn.com/v4/letter/a/df705f/32.png) [@Ayaz\_Ahmed\_Khan](https://forum.ansible.com/u/Ayaz_Ahmed_Khan)\
**Post date:** [May 8, 2015, 1:02pm UTC](https://forum.ansible.com/t/toggle-verbosity-when-running-playbooks-through-the-ansible-playbook-api/18189/1 "2015-05-08T13:02:26Z")

</div>

Hi

When I execute a playbook through the playbook Python API, is there a way to toggle the verbosity of the output? I have enabled logging for Ansible by configuring the `log_path` variable as well as by using a `log_plays` callback, but have not succeeded in achieving very verbose output of Ansible activity.

---

<div class="post-metadata">

**Author:** ![Ayaz\_Ahmed\_Khan](https://avatars.discourse-cdn.com/v4/letter/a/df705f/32.png) [@Ayaz\_Ahmed\_Khan](https://forum.ansible.com/u/Ayaz_Ahmed_Khan)\
**Post date:** [May 9, 2015, 9:49am UTC](https://forum.ansible.com/t/toggle-verbosity-when-running-playbooks-through-the-ansible-playbook-api/18189/2 "2015-05-09T09:49:21Z")

</div>

Having looked around more, I found out that the “callbacks.PlaybookCallbacks() and callbacks.PlaybookRunnerCallbacks()” both take a “verbose” parameter, the value of which by default is 0. I changed the value of that parameter to 4, which I believe corresponds to the -vvvv switch on the command-line. But it has made no difference in the verbosity of the output of the callbacks. I’m stumped.

---

<div class="post-metadata">

**Author:** ![John\_Wong](https://avatars.discourse-cdn.com/v4/letter/j/6f9a4e/32.png) [@John\_Wong](https://forum.ansible.com/u/John_Wong)\
**Post date:** [December 2, 2015, 5:40am UTC](https://forum.ansible.com/t/toggle-verbosity-when-running-playbooks-through-the-ansible-playbook-api/18189/3 "2015-12-02T05:40:01Z")

</div>

If anyone is curious, I got it working when I set the verbosity locally this way

from ansible import utils  
def foo(…)  
utils.VERBOSITY = 4  
playbook\_cb = PlaybookCallbacks(verbose=utils.VERBOSITY)

# do the same for runner if you want

I think somehow, VERBOSITY gets reset inside of Ansible.
