1. What is grains: ( static data,Minion acquisition at startup )
Grains
Static bits of information a minioncollects about the system when the Minion first starts.
The grains interface is made available Tosalt modules, and components so, the right salt minion commands areautomatical Ly available on the right systems.
The above is an official explanation, which means that grains is the static data collected at the first boot of minion, which can be used in salt modules and other components. In fact , grains every time the Minion start (restart) will be collected, that is, report to the master once.
Application Scenarios:
Grains Features – Each launch report, static determines that it is not pillar flexible, to know that pillar is changeable at any time, as long as the master side modified it will be effective immediately. So grains is more suitable for some static property value collection, such as the role of the device , the number of disks (Disk_num) andOther such very fixed properties.
Then we can get a general judgment, if you want to define the value of the property is often changed, then please use pillar, if it is very fixed, not changeable, please use grains .
Grain and Pillar differences
1.grains stores static, infrequently changing content, pillar the opposite
2.grains is stored locally on Minion, while Pillar is stored in master local
3.minion has permissions to manipulate its own grains values, such as additions, deletions, but Minion can only view its own pillar, not authorized to modify
Related commands:
Salt ' * ' Grains.ls # lists all keys for grains
Salt '*' grains.items # View all grains information, view all item
Salt ' * ' Grains.item FQDN #查看单个item
Configuration
1 Minion Configuration
Vi/etc/salt/grains
Cloud:openstack
Restart Minion to make it effective
2
Salt ' * ' grains.get cloud
This article is from the DBA Sky blog, so be sure to keep this source http://9425473.blog.51cto.com/9415473/1713354
Brief introduction of grains in Saltstack