# Environment-separated inventories ignored with cached host data

**URL:** <https://forum.ansible.com/t/environment-separated-inventories-ignored-with-cached-host-data/21880>\
**Category:** Ansible Project\
**Created:** [June 28, 2016, 6:12pm UTC](https://forum.ansible.com/t/environment-separated-inventories-ignored-with-cached-host-data/21880 "2016-06-28T18:12:03Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Guy\_Knights](https://avatars.discourse-cdn.com/v4/letter/g/db5fbb/32.png) [@Guy\_Knights](https://forum.ansible.com/u/Guy_Knights)\
**Post date:** [June 28, 2016, 6:12pm UTC](https://forum.ansible.com/t/environment-separated-inventories-ignored-with-cached-host-data/21880/1 "2016-06-28T18:12:03Z")

</div>

I have my inventory separated into environment-specific directories, with an ec2 dynamic inventory script in each inventory dir. Each ec2 inventory script filters out instances by their “Environment” tag. I run my playbooks by using the ‘-i’ command-line parameter and pointing to the specific environment inventory I want to run, which normally works.

However, I ran into an issue this morning where I was trying to run a playbook against my staging servers but ansible-playbook was instead running it over my prod servers. I re-ran it a few times, including --list-hosts to confirm the instances it was trying to apply the playbook to, but it was still using my prod inventory. I also confirmed that I was using ‘-i inventory/stage/’ in the command, which I was.

I had a thought, and removed both /tmp/ansible\_fact\_cache and ~/.ansible/tmp/\* and re-ran the exact same command, and this time my staging inventory was used correctly.

Is this a known issue? Have I configured something wrong here? I’m very confused by this behaviour.

Thanks,  
Guy

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [June 28, 2016, 7:08pm UTC](https://forum.ansible.com/t/environment-separated-inventories-ignored-with-cached-host-data/21880/2 "2016-06-28T19:08:21Z")

</div>

The fact\_cache should not be an issue unless hosts are named the same.

As for the inventory issue, are you using caching in the inventory scripts? If you are using the same cache directory names … that could explain your issue (i would add environment to the path).
