salt.modules.grains

Control aspects of the grains data

salt.modules.grains.get(key, default='')

Attempt to retrieve the named value from grains, if the named value is not available return the passed default. The default return is an empty string.

The value can also represent a value in a nested dict using a ":" delimiter for the dict. This means that if a dict in grains looks like this:

{'pkg': {'apache': 'httpd'}}

To retrieve the value associated with the apache key in the pkg dict this key can be passed:

pkg:apache

CLI Example:

salt '*' grains.get pkg:apache
salt.modules.grains.item(*args, **kargs)

Return a single component of the grains data

CLI Example:

salt '*' grains.item os

Return multiple components of the grains data

CLI Example:

salt '*' grains.item os osrelease oscodename

Sanitized CLI Example:

salt '*' grains.item host sanitize=True
salt.modules.grains.items(sanitize=False)

Return the grains data

CLI Example:

salt '*' grains.items

Sanitized CLI output:

salt '*' grains.items sanitize=True
salt.modules.grains.ls()

Return a list of all available grains

CLI Example:

salt '*' grains.ls
salt.modules.grains.setval(key, val)

Set a grains value in the grains config file

CLI Example:

salt '*' grains.setval key val

Previous topic

salt.modules.glance

Next topic

salt.modules.groupadd