LOGBOOK

HELP

Quiz Entry - updated: 2026.11.12

What are Jinja2's three kinds of delimiters, and what does each produce in the rendered file?

  • {{ EXPR }}: replaced by the value of the expression
  • {% EXPR %}: control structure (for, if), produces no text itself
  • {# COMMENT #}: comment, removed from the output

The three Jinja2 delimiters and what each leaves in the rendered file: a value, nothing but control, nothing at all

* Only {{ }} writes text; {% %} steers, {# #} disappears. *

Example template:

{# /etc/hosts line #}
{{ ansible_facts['default_ipv4']['address'] }}    {{ ansible_facts['hostname'] }}

Rendered on a host with address 192.0.2.10 and short name web1:

192.0.2.10    web1

The first line is a Jinja2 comment, so it does not appear at all. That is the difference from a comment in the target format (# ... in a config file), which would be copied into the file. Use {# #} for notes to the template's maintainers, # for notes to whoever reads the deployed file.

Go deeper:

From Quiz: ITIA / Ansible: Managing Files and Jinja2 Templates | Updated: Nov 12, 2026