How to use the Jinja templates:
1. File status using template parameter
-Template:jinja
2, template file inside variable use {{name}}, for example {{PORT}}
Variable using grains:{{grains[' FQDN_IP4 '}}
Variable using execution module: {{salt[' network.hw_addr '] (' eth0 ')}}
Variables using pillar:{{pillar[' Apache ' [' PORT ']}}
3. Variable list
-defaults:port:8080
Examples Show
[Email protected] base]# cd/srv/salt/base/[[email protected] base]# vim dns.sls/etc/resolv.conf:file.managed:-So Urce:salt://files/resolv.conf-user:root-group:root-mode:644-template:jinja-defaults:dn S_server:10.0.0.2[[email protected] base]# vim files/resolv.conf # # #hehenameserver {{dns_server}}[[email protected] Ba se]# Salt ' * ' state.highstate
This article is from the "architects of the Day" blog, be sure to keep this source http://wanyuetian.blog.51cto.com/3984643/1717289
Saltstack's Jinja Template