salt.states.grains

Manage grains on the minion

This state allows for grains to be set. Grains set or altered this way are stored in the 'grains' file on the minions, by default at: /etc/salt/grains

Note: This does NOT override any grains set in the minion file.

salt.states.grains.absent(name, destructive=False)

New in version 2014.7.0.

Delete a grain from the grains config file

name
The grain name
Parameters:destructive -- If destructive is True, delete the entire grain. If destructive is False, set the grain's value to None. Defaults to False.
grain_name:
  grains.absent
salt.states.grains.append(name, value, convert=False)

New in version 2014.7.0.

Append a value to a list in the grains config file

name
The grain name
value
The value to append
Parameters:convert -- If convert is True, convert non-list contents into a list. If convert is False and the grain contains non-list contents, an error is given. Defaults to False.
grain_name:
  grains.append:
    - value: to_be_appended
salt.states.grains.list_absent(name, value)

Delete a value from a grain formed as a list.

New in version 2014.1.0.

name
The grain name.
value
The value to delete from the grain list.

The grain should be list type

roles:
  grains.list_absent:
    - value: db

For multiple grains, the syntax looks like:

roles:
  grains.list_absent:
    - value:
      - web
      - dev
salt.states.grains.list_present(name, value)

New in version 2014.1.0.

Ensure the value is present in the list type grain.

name
The grain name.
value
The value is present in the list type grain.

The grain should be list type

roles:
  grains.list_present:
    - value: web

For multiple grains, the syntax looks like:

roles:
  grains.list_present:
    - value:
      - web
      - dev
salt.states.grains.present(name, value)

Ensure that a grain is set

name
The grain name
value
The value to set on the grain

If the grain with the given name exists, its value is updated to the new value. If the grain does not yet exist, a new grain is set to the given value.

cheese:
  grains.present:
    - value: edam