Reputation: 4392
I have some inventories defined, containing software version numbers defined in variables.
I'd like to share the same version numbers between my prod and UAT inventories in order to guarantee that a prod release matches what was tested in UAT.
Is is possible to share variables between some inventories and not others (I suppose this might mean conceptually "grouping" inventories)?
Example of my current setup
Content of /prod/group_vars/all
:
my-app-verion: 1.0.0
Content of /uat/group_vars/all
:
my-app-verion: 1.0.0
Content of /dev/group_vars/all
:
my-app-verion: LATEST
I would like to have one file that's shared by the prod
and uat
inventories and contains
my-app-verion: 1.0.0
Upvotes: 1
Views: 521
Reputation: 276
Why not use groups in inventories? There can be a release group and a latest group. Then you can have group_vars/release and group_vars/latest
Your inventory files would be:
prod:
[release]
prod1
prod2
prodlike:
[release]
prod3
prod4
test:
[latest]
dev1
dev2
mixedenv:
[releasse]
lab1
lab2
[latest]
lab3
Upvotes: 1
Reputation: 1183
You can group inventory files together by making inventory directories. Put multiple inventory files in one directory. You can then target the inventory directory when you run a playbook and Ansible will load inventory from all files in the directory.
You can also put your group_vars and host_vars directories in this directory.
Upvotes: 0