salt pillar - storing global data in pillar

[size=large]saltstack 学习之pillar[/size]
【基本介绍】
Pillar is an interface for Salt designed to offer global values that can be distributed to all minions. Pillar data is managed in a similar way as the Salt State Tree.
pillar是用来存储全局变量的,格式跟state类似

【配置】
文件:/etc/salt/master
配置pillar的路径

##### Pillar settings #####
##########################################
# Salt Pillars allow for the building of global data that can be made selectively
# available to different minions based on minion grain filtering. The Salt
# Pillar is laid out in the same fashion as the file server, with environments,
# a top file and sls files. However, pillar data does not need to be in the
# highstate format, and is generally just key/value pairs.

pillar_roots:
base:
- /srv/salt/pillar

#ext_pillar:
# - hiera: /etc/hiera.yaml
# - cmd_yaml: cat /etc/salt/yaml

# The pillar_gitfs_ssl_verify option specifies whether to ignore ssl certificate
# errors when contacting the pillar gitfs backend. You might want to set this to
# false if you're using a git backend that uses a self-signed certificate but
# keep in mind that setting this flag to anything other than the default of True
# is a security concern, you may want to try using the ssh transport.
#pillar_gitfs_ssl_verify: True

# The pillar_opts option adds the master configuration file data to a dict in
# the pillar called "master". This is used to set simple configurations in the
# master config file that can then be used on minions.
#pillar_opts: True


【原则】
pillar namespace
1.merge content from multiple pillar files,so long as conflicts are avoided(整合变量忽略冲突的)

【使用】
salt '*' pillar.items 还回所有的pillar
使用方法:{{ pillar['foo'] }}
{{ salt['pillar.get']('foo', 'qux') }}

在state里面使用pillar
[code="linux"]
# cat top.sls
base:
'*':
- packages
# cat packages.sls
hn: hostname
# cat /srv/salt/sls_config/test.sls
This is test:
cmd.run:
- name: {{ pillar['hn']}}
#
[/code]


【参考】
[url]http://docs.saltstack.com/en/latest/topics/pillar/[/url]
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值