saltstack之jinja模板
jinjia基础基于python
state文件中使用"- template:jinjia"声明
模版文件中声明变量"{{ name }}"name变量明
state文件中"-defautls:name:value"声明
使用变量
{{变量}}
一级字典变量{{pillar['appname']}}
二级字典变量{{pillar['flow']['maxconn']}}
判断语句
{%if grains['os'] == 'CentOS'%}
apache: httpd
{% elif grains['os'] == 'Debian' %}
apache:apache2
{% endif %}
for循环
{%for user,uid in pillar.get('users',{}).items() %}
{{user}}:
user.present:
[*]uid:{{uid}} {{%endfor%}}
页:
[1]