Saltstack's Jinja Template

Source: Internet
Author: User
Tags saltstack

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.