I'm trying to set up a (hopefully) simple Ansible script to check out a git branch. There are three environments: dev, qa, and live. Each spans two hosts. But dev and qa use the same hosts, just using different directories.
I'd like to have an inventory file sorta like this:
[dev]
internal1.example.com
internal2.example.com
[dev:vars]
dir = /opt/dev
[qa]
internal1.example.com
internal2.example.com
[qa:vars]
dir = /opt/qa
[live]
live1.example.com
live2.example.com
[live:vars]
dir = /opt/live
But this doesn't work. Variable values are taken from all groups they belong to. So internal1.example.com picks up the dir value from both dev and qa, regardless of which one I'm trying to deploy.
How can I assign a variable that applies to a host depending on which group I am targeting?
I'm using Ansible version 1.5.4.