LOGBOOK

HELP

Quiz Entry - updated: 2026.11.12

How does the ansible.builtin.template module deploy a template, and where is it rendered?

src names the template on the control node, dest the file on the managed host; Ansible renders the template on the control node with the host's variables and facts, then transfers the result like copy.

Template rendering: templates/test.j2 and the host's facts are combined on the control node, and the rendered file is copied to /tmp/hostname on each host

* Rendered on the control node, once per host, then copied like any file. *

- name: write hostname using jinja2
  ansible.builtin.template:
    src: templates/test.j2
    dest: /tmp/hostname

with templates/test.j2:

My name is {{ ansible_facts['hostname'] }}

On host web1 the file /tmp/hostname contains My name is web1.

Rendering happens on the control node, so the managed hosts need neither Jinja2 nor the template file. For each host, Ansible renders a separate result (that host's facts, that host's variables) and then behaves like copy: compare checksums, replace the file only if the content differs, report changed or ok. That is why a template task can notify a restart handler that fires only when the rendered config actually changed.

Go deeper:

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