This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| automation:jinja2 [2017/05/27 13:58] – created jotasandoku | automation:jinja2 [2023/11/02 14:38] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| **JINYA**\\ | **JINYA**\\ | ||
| - | It uses a template file (jinja) and a // | + | * Nice examples: https:// |
| + | * It uses a template file (jinja) and a // | ||
| + | * All the links plus a tutorial can be found [[http:// | ||
| + | * Loop with variable and multiple template and targets : [[http:// | ||
| + | \\ | ||
| + | Note that, in Ansible, ROLES are the ones that generate the configurations, | ||
| + | \\ | ||
| + | VARIABLE | ||
| + | time-zone {{ location.time_zone }}; | ||
| + | FOR LOOP | ||
| + | {% for name_server in location.name_servers %} | ||
| + | {{ name_server }}; | ||
| + | {% endfor %} | ||
| + | IF STATEMENTS | ||
| + | {% if item[0] is short_caption %} | ||
| + | {# do something here #} | ||
| + | {% endif %} | ||
| + | INCLUDING CONTENT OF FILES IN THE RENDERED TEMPLATE: | ||
| + | system{ | ||
| + | {% include " | ||
| + | {% include " | ||
| + | } | ||
| + | INCLUDING BLOCKS:\\ | ||
| + | Note that this is the parent configuration, | ||
| + | services { | ||
| + | ssh; | ||
| + | {% block dhcp %} | ||
| + | dhcp{ | ||
| + | pool 0.0.0.0/ | ||
| + | } | ||
| + | {% endblock dhcp %} | ||
| + | } | ||