Thomas
Thomas

Reputation: 791

ansible variables in inventory

Is it possible to store variables in inventory files?

My inventories looks like this:

[a]
host1
[b]
host2
[Dev:children]
a
b


[a]
host3
[b]
host4
[Dev:children]
a
b

As you can see Both inventories are used on Dev vars (because 99% percent of the variables are the same) but few of them differ. Is that possible to add them to role just by running the role with correct inventory?

Upvotes: 1

Views: 1194

Answers (1)

Thomas
Thomas

Reputation: 791

Of course the answer is: Ansible - variables in inventory

To put it simply, just use the following syntax:

[a:vars]
var=abc

By running the role with that directory, you can user variable var :)

Upvotes: 1

Related Questions