Salt Grains

Salt comes with an interface to derive information about the underlying system. This is called the grains interface, because it presents salt with grains of information. Grains are collected for the operating system, domain name, IP address, kernel, OS type, memory, and many other system properties.

Salt Grains system

The grains interface is made available to Salt modules and components so that the right salt minion commands are automatically available on the right systems.

Grain data is relatively static, though if system information changes (for example, if network settings are changed), or if a new value is assigned to a custom grain, grain data is refreshed.

Lab: Viewing system data

This module display the inline documentation for all available modules, or for the specified module or function.

cfg01# salt 'svc*' sys.doc pkg

'pkg.autoremove:'

    New in version 2015.5.0

    Remove packages not required by another package using ``apt-get
    autoremove``.

    list_only : False
        Only retrieve the list of packages to be auto-removed, do not actually
        perform the auto-removal.


    CLI Example:

        salt '*' pkg.autoremove
        salt '*' pkg.autoremove list_only=True

    ...

Running grain.items module will return all of the minion’s grains.

cfg01# salt 'svc*' grains.items
svc01.saltstack.local:
----------
SSDs:
biosreleasedate:
    04/01/2014
biosversion:
    1.7.5-20150310_111955-batsu
cpu_flags:
    - fpu
    - vme
    - de
...
svc02.saltstack.local:
----------
SSDs:
biosreleasedate:
    04/01/2014
biosversion:
    1.7.5-20150310_111955-batsu
cpu_flags:
    - fpu
    - vme
    - de
...