首页 > 其他 > 详细

saltstack数据系统之Pillar

时间:2015-11-18 18:11:46      阅读:378      评论:0      收藏:0      [点我收藏+]

在master上面打开系统自带的pillar:

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

556 pillar_opts: True

[root@linux-node1 ~]# /etc/init.d/salt-master restart

Stopping salt-master daemon:                               [确定]

Starting salt-master daemon:                               [确定]


[root@linux-node1 ~]# salt ‘*‘ pillar.items                 =======>显示系统自带的pillar


pillar的应用场景:

1   敏感数据:如用户名与密码

2   处理差异性变量


[root@linux-node1 ~]# vim /etc/salt/master    ==========>打开如下选项

533 pillar_roots:

534   base:

535     - /srv/pillar

556 pillar_opts: False


[root@linux-node1 srv]# mkdir pillar


[root@linux-node1 srv]# /etc/init.d/salt-master restart

Stopping salt-master daemon:                               [确定]

Starting salt-master daemon:                               [确定]


实例1:

[root@linux-node1 pillar]# cat /srv/pillar/apache.sls

{% if grains[‘os‘] == ‘CentOS‘ %}     如果系统是CentOS

apache: httpd                         则显示httpd

{% elif grains[‘os‘] == ‘Debian‘ %}   如果系统是Debian

apache: apache2                       则显示apache2

{% endif %}


[root@linux-node1 pillar]# cat /srv/pillar/top.sls    ========>pillar的top file文件

base:

  ‘*‘:

    - apache


[root@linux-node1 pillar]# salt ‘*‘ pillar.items       ========>获取pillar的值

linux-node2.example.com:

    ----------

    apache:

        httpd

linux-node1.example.com:

    ----------

    apache:

        httpd


实例2:定位主机

[root@linux-node1 pillar]# salt ‘*‘ saltutil.refresh_pillar         =======>刷新pillar

linux-node1.example.com:

    True

linux-node2.example.com:

    True


[root@linux-node1 pillar]# salt -I ‘apache:httpd‘ test.ping         =========>定位主机

linux-node2.example.com:

    True

linux-node1.example.com:

    True


老男孩网址:http://www.etiantian.org/

qq:406564728

欢迎提出宝贵建议

本文出自 “linux” 博客,请务必保留此出处http://chenjisong.blog.51cto.com/7858025/1714022

saltstack数据系统之Pillar

原文:http://chenjisong.blog.51cto.com/7858025/1714022

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!