mouse 发表于 2018-7-31 07:33:19

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]
查看完整版本: saltstack之jinja模板