Template

Learn how to generate an entire file dynamically using a mix of static content, variable data, and control logic.

Introduction to Ansible template

An Ansible template generates an entire file dynamically using a mix of static content, variable data, and control logic. The ansible.builtin.template module is a flexible and powerful way to generate configuration content. Templates are regular files with embedded controls and variable references.

Ansible template works by taking advantage of the Jinja2 programming language, the Ansible built-in template module. The Jinja template file is stored under the templates directory. We can add variable references using the {{ variable }} syntax in the template to make the content dynamic.

The files are stored in ...