saltstack数据系统——pillar
pillar 存储位置:master端,数据类型:动态数据 ,数据采集方式:在master端定义,指定给对应的minion。可以使用saltuitl.refresh_pillar刷新。
应用:存储master指定的数据。只有指定的minion可以看到。用于敏感数据保存。
通过一个例子来了解:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
###salt '*' pillar.items
###默认是没有显示的,需在打开配置选项,我们演示完后,把这一项还原回来
###vim /etc/salt/master
###552行,pillar_opts: True
###重启服务/etc/init.d/salt-master restart
###再次执行salt '*' pillar.items 就会有显示啦
########################定义pillar数据#######################################
vim /etc/salt/master
打开下面三行:
pillar_roots:
base:
- /srv/pillar
保存退出
mkdir /srv/pillar
/etc/init.d/salt-master restart
#################################################################################
vim /srv/pillar/apache.sls
{% if grains['os'] == 'CentOS' %}
apache: httpd
{% elif grains['os'] == 'Debian' %}
apache: apache2
{% endif %}
##################################################################################
vim /srv/pillar/top.sls
base:
'*':
- apache
######################################################################################
salt '*' saltutil.refresh_pillar#刷新一下
salt '*' pillar.items
######################################pillar定位主机 ##############################
salt -I 'apache:httpd' test.ping
页:
[1]