group_vars and limits

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

`

This question has been asked on this forum quite a few times this week. Search for “–limit” among recent posts if you don’t mind.

Thanks!

I found one post which was somewhat similar, which mentioned doing what I’ve come up with to address this in the meantime (passing in an extra var which will get run by an include_vars task) but it seems kind of silly to add that to the beginning of every task list when it could be more simply handled by --limit, not to mention redundant in having to set the exact same environment name for both limit and extra_vars when running an ansible tower job template.

But it’ll definitely work. Appreciate your time.

It’s not silly, so much as --limit doing what it says it is supposed to do.

However, see my proposal about --limit setting a default and being able to also set “limit: all” on some tasks, such that it’s possible to control the limit per play, and only have --limit pass it in for some.

I think that’s what we need to do.