Jinja2 yaml indent. I am wondering if there is any way to keep the indentation with jinja when adding a include or macro inside a file. An example would be File: c Jinja's Template Designer Documentation explains how to create and use templates with special placeholders, macros, and inheritance for dynamic content rendering. Apr 12, 2021 · How to fix Jinja2 yml indentation Ask Question Asked 4 years, 10 months ago Modified 4 years, 10 months ago Dec 16, 2025 · Jinja2 is Ansible’s go-to templating engine, powering dynamic configuration files, scripts, and reports. Nov 28, 2023 · If you don’t want your indentation get messed up for example in a docker-compose file, add this to the very first line. j2 using Jinja2 syntax Highlights *. For example, the template below does what you're looking for Apr 12, 2021 · How to fix Jinja2 yml indentation Ask Question Asked 4 years, 10 months ago Modified 4 years, 10 months ago Mar 29, 2019 · Background: This is an Ansible playbook using templates to CONSTRUCT a yaml file from a template. yaml, *. A common challenge when working with Jinja2 templates is balancing **readability of the template itself** (via proper indentation of `{% %}` control blocks like `if`/`for`) with **correctness of the rendered output** (avoiding unintended whitespace or indentation in the final file). Constructor() yaml. So basically I have a jinja2 template file with a line as such: private_key: {{ myvar }} Ansibl We would like to show you a description here but the site won’t allow us.