Jinja
A templating language for Python tools that fills placeholders in text, written inside double curly braces, with values and simple logic.
In more detail
{{ name }} is replaced by a variable's value, {% ... %} holds logic such as loops and conditions, and filters such as default transform values. It is used by Ansible, by Python web frameworks such as Flask and by many other tools.
Examples
msg: "core {{ ansible_version.full }}" in an Ansible debug task.when: conditions in Ansible are bare Jinja expressions without braces.Related terms
- Jinja template — A text file containing Jinja expressions that Ansible fills in with each host's variables to produce a finished file.
- template module — The module that fills in a Jinja template with variables and writes the result to a file on each host.
- Ansible variable — A named value, such as http_port or site_name, that tasks and templates refer to instead of writing the value in directly.
- when condition — A task keyword holding an expression; the task runs on a host only if the expression is true there, and is reported as skipped otherwise.
Taught in
- Installing Ansible — Ansible Configuration Management at Scale
- Variables And Precedence — Ansible Configuration Management at Scale
- Conditionals — Ansible Configuration Management at Scale
- Loops — Ansible Configuration Management at Scale
- Templates With Jinja — Ansible Configuration Management at Scale
- The Standard Directory Layout And Roles — Ansible Configuration Management at Scale
- Variables And Where They Win: group_vars, host_vars And Play Vars — RHCE in Ansible (EX294): Automate Red Hat Systems
- Conditionals: register, when, changed_when And failed_when — RHCE in Ansible (EX294): Automate Red Hat Systems
- Archives: archive And unarchive On The Managed Nodes — RHCE in Ansible (EX294): Automate Red Hat Systems
- Users And Groups From A List, With Passwords That Settle — RHCE in Ansible (EX294): Automate Red Hat Systems
- Jinja Templates: One File, A Different Text Per Host — RHCE in Ansible (EX294): Automate Red Hat Systems