LOGBOOK

HELP

Quiz Entry - updated: 2026.11.12

What is ansible_managed for, how do you use it in a template, and how should it be set in current Ansible?

It puts a "this file is managed by Ansible" note at the top of deployed files, so nobody edits them by hand; write # {{ ansible_managed }} in the template. The old ansible_managed = ... setting in ansible.cfg is deprecated; set it as a normal variable instead.

# {{ ansible_managed }}
# DO NOT MAKE LOCAL MODIFICATIONS TO THIS FILE BECAUSE THEY WILL BE LOST

Rendered: # Ansible managed followed by the warning.

A template overwrites the whole file on every run where the content differs. An admin who fixes something directly on the host loses that fix at the next run, often without noticing. The header tells them to change the template (or its variables) instead.

How the text is defined:

  • Older way (still common in material): ansible_managed = Ansible managed in the [defaults] section of ansible.cfg. That setting is deprecated, scheduled for removal in ansible-core 2.23.
  • Current way: set ansible_managed like any other variable, for example in group_vars/all.yml, or use your own variable name.

Either way, put it inside the target format's comment syntax (#, ;, <!-- -->); the variable only supplies the text.

Go deeper:

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