# How can we prevent 2 Ansible playbook to run on the same host at the same time?

**URL:** <https://forum.ansible.com/t/how-can-we-prevent-2-ansible-playbook-to-run-on-the-same-host-at-the-same-time/32557>\
**Category:** Ansible Project\
**Created:** [March 30, 2020, 5:35am UTC](https://forum.ansible.com/t/how-can-we-prevent-2-ansible-playbook-to-run-on-the-same-host-at-the-same-time/32557 "2020-03-30T05:35:08Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tamar\_matelles](https://avatars.discourse-cdn.com/v4/letter/t/7feea3/32.png) [@tamar\_matelles](https://forum.ansible.com/u/tamar_matelles)\
**Post date:** [March 30, 2020, 5:35am UTC](https://forum.ansible.com/t/how-can-we-prevent-2-ansible-playbook-to-run-on-the-same-host-at-the-same-time/32557/1 "2020-03-30T05:35:08Z")

</div>

?How can we prevent from 2 ansible running on the same host at the same time  
we are working with facts\_catch json file and sometimes have problem that 2 ansibles try write the same json

fact\_caching = jsonfile  
fact\_caching\_connection = /tmp/facts\_cache  
fact\_caching\_timeout = 7200

---

<div class="post-metadata">

**Author:** ![sivel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sivel/32/1198_2.png) [@sivel](https://forum.ansible.com/u/sivel)\
**Post date:** [March 30, 2020, 3:09pm UTC](https://forum.ansible.com/t/how-can-we-prevent-2-ansible-playbook-to-run-on-the-same-host-at-the-same-time/32557/2 "2020-03-30T15:09:34Z")

</div>

Any file based operations that affect the controller are going to be dangerous if multiple processes are trying to do them. If you know this is going to be a common pattern, where multiple playbook executions are happening simultaneously, I’d recommend a database backed fact caching mechanism, such a redis.

There is no fool proof way of ensuring that multiple ansible invocations cannot be run simultaneously.
