etc/salt/minion override both core grains and custom grain modules, and The order of evaluation is as follows:Ĭustom grain modules in _grains directory, synced to minions.Įach successive evaluation overrides the previous ones, so any grains definedīy custom grains modules synced to minions that have the same name as a core As there are several ways ofĭefining custom grains, there is an order of precedence which should be kept in Local: - foo: bar hello: world my_grains: - foo: bar hello: world Precedence ¶Ĭore grains can be overridden by custom grains. So there's no need to place information in grains to make it available to Jinja Referencing pillar data as well as invoking functions from execution modules, Also, keep in mind that Jinja templating in Salt supports The grain should be designed to support many platforms, operating systems orĪpplications. Good candidates for grains are data that is useful for targeting minions in the That system commands be run, then putting this information in an execution If the data is something that is likely to change, consider using Pillar or an execution module instead. Should (for the most part) be static data. When to Use a Custom Grain ¶īefore adding new grains, consider what the data is and remember that grains The name of the function does not matter and will not factor into the grainsĭata at all only the keys/values returned become part of the grains. Grains modules are easy to write, and (as noted above) only need to return aĭef yourfunction (): # initialize a grains dictionary grains = # Some code for logic that sets grains like grains = True grains = "somevalue" return grains Will be distributed to the minions when state.highstate is run, or by executing the The default path would be /srv/salt/_grains. Located under the file_roots specified by the master configįile. Theįunctions in a grains module must return a Python dictionary, where the dictionary keys are the names of grains, andĮach key's value is that value for that grain.Ĭustom grains modules should be placed in a subdirectory named _grains Salt's core grains code, followed by those in any custom grains modules. Which do not begin with an underscore) found in the modules located in the The grains are derived by executing all of the "public" functions (i.e. Use of Storing Static Data in the Pillar and/or Storing Data in Other Databases. Storing sensitive data, such as passwords or keys, on minions. The local system, making them less secure than other identifiers in Salt. Grains can be set by users that have access to the minion configuration files on
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |