Jinja2 templates

What is Jinja all about? Jinja2 is a very popular and powerful Python-based template engine. Since Ansible is written in Python, it becomes the default choice for most users, just like other Python-based configuration management systems, such as Fabric and SaltStack. The name Jinja originated from the Japanese word for temple, which is similar in phonetics to the word template.

Some of the important features of Jinja2 are:

  • It is fast and compiled just in time with the Python byte code
  • It has an optional sandboxed environment
  • It is easy to debug
  • It supports template inheritance

The template formation

Templates look very similar to normal text-based files except for the occasional variables or code that surrounds the special tags. These ...

Get Ansible Playbook Essentials now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.