zdc253212956 发表于 2018-7-31 10:19:13

saltstack数据系统——pillar

###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]
查看完整版本: saltstack数据系统——pillar