# Prevent caching when calling ansible 2.0 from Python API

**URL:** <https://forum.ansible.com/t/prevent-caching-when-calling-ansible-2-0-from-python-api/20706>\
**Category:** Ansible Project\
**Created:** [February 29, 2016, 3:59pm UTC](https://forum.ansible.com/t/prevent-caching-when-calling-ansible-2-0-from-python-api/20706 "2016-02-29T15:59:08Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![max.wiegand82](https://avatars.discourse-cdn.com/v4/letter/m/bc79bd/32.png) [@max.wiegand82](https://forum.ansible.com/u/max.wiegand82)\
**Post date:** [February 29, 2016, 3:59pm UTC](https://forum.ansible.com/t/prevent-caching-when-calling-ansible-2-0-from-python-api/20706/1 "2016-02-29T15:59:08Z")

</div>

Hi all,

our general setup is based on the idea to have an ansible environment with roles and vars and everything, that can be used  
both by command line and also programatically from python. It was quite easy with ansible 1.9, but i struggle to get it with  
newer ansible 2.0.  
Here is the point, i can’t get fixed:

In python:

> _from ansible.cli.playbook import \*_
> 
> _from ansible.executor.playbook\_executor import \*_
> 
> _from ansible.utils.vars import combine\_vars_
> 
> _my\_cli=PlaybookCLI([‘’, ‘/amplay/reboot.yml’,‘-i’,‘/amplay/hosts’,‘-l’,‘nuc5’])_
> 
> _my\_cli.parse()_
> 
> _results=my\_cli.run()_

Output:

> _PLAY [Start Protected] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*_
> 
> _TASK [twist-protected : include] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*_
> 
> _included: /amplay/roles/twist-protected/tasks/start-protected.yml for nuc5_
> 
> _TASK [twist-protected : Workaround delegate\_to user name problem] \*\*\*\*\*\*\*\*\*\*\*\*\*\*_
> 
> _ok: [nuc5]_
> 
> _TASK [twist-protected : Check Twistprotected] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*_
> 
> _ok: [nuc5 → localhost]_
> 
> _…_

Now i run the same code a second time:

> _my\_cli=PlaybookCLI([‘’, ‘/amplay/reboot.yml’,‘-i’,‘/amplay/hosts’,‘-l’,‘nuc5’])_
> 
> _my\_cli.parse()_
> 
> _results=my\_cli.run()_

Output:

> _PLAY [Start Protected] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*_
> 
> _TASK [twist-protected : include] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*_
> 
> _included: /amplay/roles/twist-protected/tasks/start-protected.yml for nuc5_
> 
> _TASK [twist-protected : include] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*_
> 
> _included: /amplay/roles/twist-protected/tasks/setup-proxy.yml for nuc5_
> 
> _…_

It does not execute the tasks, but just skips without any message!  
Apparently there is some caching or similar, that tells ansible not to repeat the execution of the playbook.  
This might make sense for some scenarios, but how can i switch it off? I tried with `flush-cache` cmd line  
option, but that didn’t change anything.

Any hints?
