saltstack中grains简介
1.什么是grains:(靜態(tài)數(shù)據(jù),minion啟動(dòng)時(shí)采集)
?
Grains
Static bits of information that a minioncollects about the system when the minion first starts.
The grains interface is made available toSalt modules and components so that the right salt minion commands areautomatically available on the right systems.
?
以上是官方的解釋,大致意思是說(shuō)grains是minion第一次啟動(dòng)的時(shí)候采集的靜態(tài)數(shù)據(jù),可以用在salt的模塊和其他組件中。其實(shí)grains在每次的minion啟動(dòng)(重啟)的時(shí)候都會(huì)采集,即向master匯報(bào)一次的。
應(yīng)用場(chǎng)景:
?grains的特性–每次啟動(dòng)匯報(bào)、靜態(tài)決定了它沒(méi)有pillar靈活,要知道pillar是隨時(shí)可變的,只要在master端修改了那一般都會(huì)立刻生效的。所以grains更適合做一些靜態(tài)的屬性值的采集,例如設(shè)備的角色(role),磁盤(pán)個(gè)數(shù)(disk_num)等諸如此類非常固定的屬性。
?
?那么我們就可以得到一個(gè)大致的判斷,如果你想定義的屬性值是經(jīng)常變化的,那請(qǐng)采用pillar,如果是很固定、不易變的那請(qǐng)用grains。
grain和pillar區(qū)別
1.grains存儲(chǔ)的是靜態(tài)、不常變化的內(nèi)容,pillar則相反
2.grains是存儲(chǔ)在minion本地,而pillar存儲(chǔ)在master本地
3.minion有權(quán)限操作自己的grains值,如增加、刪除,但minion只能查看自己的pillar,無(wú)權(quán)修改
相關(guān)命令:
salt '*' grains.ls #列出grains的所有key
?
salt ‘*’ grains.items # 查看所有grains信息,查看所有item
salt '*' grains.item fqdn #查看單個(gè)item
配置
1 minion配置
vi /etc/salt/grains
cloud: openstack
重啟minion使其生效
2?
salt '*' grains.get cloud
轉(zhuǎn)載于:https://blog.51cto.com/9425473/1713354
總結(jié)
以上是生活随笔為你收集整理的saltstack中grains简介的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
 
                            
                        - 上一篇: win32 控件的创建和消息响应
- 下一篇: 自连接什么时候要用
