Environment-separated inventories ignored with cached host data

3 views
Skip to first unread message

Guy Knights

unread,
Jun 28, 2016, 2:12:13 PM6/28/16
to ansible...@googlegroups.com
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

Brian Coca

unread,
Jun 28, 2016, 3:08:33 PM6/28/16
to ansible...@googlegroups.com
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).


----------
Brian Coca
Reply all
Reply to author
Forward
0 new messages