salt-stack的数据系统Pillars

Pillar 动态的,给特定的Minion指定特定的数据,只有指定的Minion自己能看到自己的数据

[root@salt-master ~]# vim /etc/salt/master

pillar_opts: False                                          //把false改为True

[root@salt-master ~]# salt '*' pillar.items     //需要修改配置文件才能看到items

salt-minion:
    ----------
salt-master:

[root@salt-master ~]# vim /etc/salt/master         //修改master的配置文件

pillar_roots:
  base:
    - /srv/pillar

[root@salt-master ~]# mkdir /srv/pillar

[root@salt-master ~]# systemctl restart salt-master        //重启master

例:
1、先编写sls文件
[root@salt-master /srv/pillar/web]# vim apache.sls

{% if grains['os'] == 'CentOS' %}
apache: httpd
{% elif grains['os'] == 'Debian' %}
apache: apache2
{% endif %}

2、写top_file文件,指定谁执行状态
[root@salt-master /srv/pillar]# vim top.sls         //主要指定哪些主机执行sls文件

base:
  'salt-minion':
    - web.apache

[root@salt-master /srv/pillar]# salt '*' saltutil.refresh_pillar     / /刷新pillar
salt-master:
    True
salt-minion:
    True

[root@salt-master /srv/pillar]# salt '*' pillar.items apache     //执行自定义pillar状态
salt-minion:
    ----------
    apache:
        httpd
salt-master:
    ----------
    apache:

  

  

posted @ 2019-06-19 22:28  北方莜蓝  阅读(129)  评论(0编辑  收藏  举报