How can I use multiple grain files and organise them in directories :
# pwd /etc/salt
This is just an example:
etc └── salt └── minion ├── minion ├── grains_1 ├── app_name └── grains_2
Or I am obliged to keep all in
grains file ?
Interesting question. I looked into the code and it looks like the grain loader does not recurse through directories. You can supply a
grains_dir option in your minion config as an extra place to look for grains which may get you what you're looking for.
SaltStack grains use the following precedence scheme for loading grains.
osgrain where SaltStack derives info from the system itself).
/etc/salt/grains(YAML file you could add custome grains to).
/etc/salt/minion(the minion config file).
Dynamic grains (EC2 example)
You could use something to dynamically set the grains for a minion, a good example of this is the ec2_tags grains module which basically makes a grain based on EC2 tags assigned to the instance.