本文共 1781 字,大约阅读时间需要 5 分钟。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | grains 和 pillar vim / etc / salt / grains role: nginx env: test myname: tpp / etc / init.d / salt - minion restart salt 'slaver.test.com' grains.item role env myname salt - G role:nginx cmd.run 'hostname' pillar 和 grains 不一样,是在 master 上定义的,并且是针对 minion 定义的一些信息 salt 'slaver.test.com' pillar.items http: / / msiyuetian.blog. 51cto .com / 8637744 / 1745785 [root@nginx pillar] # tree . ├── test.sls └── top.sls [root@nginx pillar] # cat *.sls conf: / etc / 123.conf myname: tpp base: 'cm1' : - test pillar刷新 salt '*' saltutil.refresh_pillar salt - I 'conf:/etc/123.conf' test.ping |
salt grains与pillar jinja的模板
1.先学会salt grains与pillar
2.saltstack应用之简化pillar配置步骤
3.Saltstack用pillar(jinjia)来渲染需要同步的配置文件
一个简单的例子:同步zabbix的配置文件到8台minion
http://blog.csdn.net/tmpbook/article/details/41858369
# egrep -v "(^#|^$)" /etc/zabbix/zabbix_agentd.conf
PidFile=/var/run/zabbix/zabbix_agentd.pid
LogFile=/var/log/zabbix/zabbix_agentd.log
LogFileSize=1
Server=192.168.46.184
ServerActive=192.168.46.184,192.168.46.185
Hostname=(这里要是minion端的ip)
UnsafeUserParameters=1
Include=/etc/zabbix/zabbix_agentd.d/
结构
1.pillar->zabbix->ip.sls
ip: {
{ grains['ipv4'][1] }}2.jinja state.sls
zabbix:
file.managed:
- source: salt://zabbix/zabbix_agentd.conf
- name: /etc/zabbix/zabbix_agentd.conf
- template: jinja
- defaults:
ip: { { pillar['ip'] }}
模板存新值
3.调用模板
vim zabbix_agentd.conf
PidFile=/var/run/zabbix/zabbix_agentd.pid
LogFile=/var/log/zabbix/zabbix_agentd.log
LogFileSize=1
Server=192.168.46.184
ServerActive=192.168.46.184,192.168.46.185
Hostname=` ip `
UnsafeUserParameters=1
Include=/etc/zabbix/zabbix_agentd.d/
4.至于top.sls的写法
增加pillar目录