saltstack grains

The grain interface is some information about the underlying system,it is available for all the Salt module and compounts

salt  'host' grains.ls # to list all the grains in  the salt minion of the  host

salt "host" grains.items # to show all the items in the salt minion whose host is host

salt "host" grains.item  os (or certain item) # to show the certain items in the salt minion

self-define grains in salt minions

edit /etc/salt/grains ,the contents like following:

roles:
  - webserver
    - memcache
deployment: datacenter4
cabinet: 13
cab_u: 14-15

restart salt-minion and  run salt 'host' grains.ls ,you will find the new grain u add

notice the blank between the  key and  value of "cab_u: 14-15"

use grains in command lines  like following:

salt -G 'os:CentOS' test.ping #matching all the Centos minions
salt -C 'G@circle:live and G@data_volume_attached:True' #use grains matching in compound matching

use grains in top.sls files:

'node_type:web':
  - match: grain
  - webserver

'node_type:postgres':
  - match: grain
  - database

'node_type:redis':
  - match: grain
  - redis

'node_type:lb':
  - match: grain
  - lb

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值