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 %}}