It is said in saltstack documentation that adding :
{% set node_type = salt['grains.get']('node_type', '') %}
{% if node_type %}
'node_type:{{ self }}':
- match: grain
- {{ self }}
{% endif %}
to
/srv/salt/top.sls
will create a grain called node_type
I added the code below to the top file, and I would like to know why I can't see node_type
in my minion :
myHost ~ # service salt-master restart; service salt-minion restart;
myHost ~ # salt '*' grains.get "node*"
The last command returns nothing. And I think it is normal because I haven't defined node_type
in /etc/salt/grains
This makes me ask a question : what is the difference between :
- Declaring node_type in
top.sls
file
and
- Adding it simply to grains file (
/etc/salt/grains
) or to minion file (/etc/salt/minion
)