How can I use multiple grain files and organise them in directories :

# pwd

This is just an example:

└── salt
    └── minion
          ├── minion
          ├── grains_1
          ├── app_name
              └── grains_2

Or I am obliged to keep all in minion and 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.

Grain loading

SaltStack grains use the following precedence scheme for loading grains.

  • Core grains (this is stuff like the os grain where SaltStack derives info from the system itself).
  • Custom grains in /etc/salt/grains (YAML file you could add custome grains to).
  • Custom grains in /etc/salt/minion (the minion config file).
  • Custom grain modules in _grains directory, synced to minions.

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.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.