Background
We use ansible for all our automated deployments, and have had success in managing separate environment configuration using group vars. Our inventories (running locally and also on ansible tower) have hosts belonging to groups based on application and environment – for example, we might run something like this:
ansible-playbook -i inventories/non-prod -l'env-qa:&backend' backend/deploy.yml
… to deploy to all hosts belonging to the backend group and the env-qa group, and to pull in config values from group_vars/env-qa.
Recently we’ve decided to use a single cluster of machines for deploying applications which belong to different environments - for example, with apps like Storm, you can run two different qa environments on the same cluster. Where we’re running into problems is that even if we set the limit flag on ansible-playbook to ‘env-qa-1’, we’re still getting all the variables belonging to ‘env-qa-2’ when we actually run the playbook. I’ve simplified this below.
Files:
inventories/test
`
[group-a]
host1
[group-b]
host1
[app]
host1
`
group_vars/group-a
`