netapi
modulessalt.modules.defaults.
get
(key, default='')¶defaults.get is used much like pillar.get except that it will read a default value for a pillar from defaults.json or defaults.yaml files that are stored in the root of a salt formula.
When called from the CLI it works exactly like pillar.get.
CLI Example:
salt '*' defaults.get core:users:root
When called from an SLS file, it works by first reading a defaults.json and second a defaults.yaml file. If the key exists in these files and does not exist in a pillar named after the formula, the value from the defaults file is used.
Example core/defaults.json file for the 'core' formula:
{
"users": {
"root": 0
}
}
With this, from a state file you can use salt['defaults.get']('users:root') to read the '0' value from defaults.json if a core:users:root pillar key is not defined.