[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 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]