What is `ansible_managed` and why put it in templates?
IntermediateConceptJinja2, Conditionals and Loops
Answer
{{ ansible_managed }} renders a header string, by default Ansible managed, that you can customise in ansible.cfg (ansible_managed = ...). Putting it at the top of every templated file tells the next admin the file is generated, and that manual edits will be overwritten.
Avoid putting timestamps or hostnames in it. They change on every run and make the template task report changed every time.
More on Jinja2, Conditionals and Loops
What role does Jinja2 play in Ansible?BeginnerWhat are the three Jinja2 delimiters?BeginnerShow a template with a loop and a conditional, and how it is deployed.BeginnerWhich filters do you use every day?BeginnerHow do you transform lists and dicts with filters (`map`, `select`, `selectattr`, `unique`, `flatten`)?IntermediateHow does `when` work and which operators can you use?Beginner