给数据定义需要的数据:
应用场景:
指定敏感的数据:
指定特定的的用户可以看到指定的数据
在服务端master上指定,不需要在客户端配置
可以用来定位目录机器
查看pillar明细:
[root@node110 states]# salt '*' pillar.items
minion.saltstack.com:
----------
minion.node2.saltstack.com:
----------
修改配置文件:
# a top file and sls files. However, pillar data does notneed to be in the
# highstate format, and is generally just key/valuepairs.
pillar_roots:
base:
-/etc/salt/pillar
#
#ext_pillar:
# - hiera:/etc/hiera.yaml
创建目录:
mkdir /etc/salt/pillar
touch top.sls
[root@node110 pillar]# cat top.sls
base:
'*':
- init.rsyslog
[root@node110 pillar]# mkdir init
[root@node110 pillar]# pwd
/etc/salt/pillar/init
[root@node110 init]# cat rsyslog.sls
{% if grains['osfinger'] == 'CentOS-6' %}
syslog: rsyslog
{% elif grains['osfinger' == 'CentOS-5']%}
syslog: syslog
{% endif %}
[root@node110 pillar]# pwd
/etc/salt/pillar
[root@node110 pillar]# ls -F
init/ top.sls
[root@node110 pillar]# tree
.
|-- init
| `-- rsyslog.sls
`-- top.sls
1 directory, 2 files
[root@node110 pillar]# salt '*' saltutil.refresh_pillar #刷新pillar
minion.saltstack.com:
True
minion.node2.saltstack.com:
True
重新启动服务:
[root@node110 pillar]# /etc/init.d/salt-master restart
Stopping salt-master daemon: [ OK ]
Starting salt-master daemon: [ OK ]
测试:
[root@node110 pillar]# salt '*' pillar.item syslog
minion.saltstack.com:
----------
syslog:
rsyslog
minion.node2.saltstack.com:
----------
syslog:
rsyslog