Interview Prep/Ansible/Jinja2, Conditionals and Loops

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.

All Ansible questions Roadmap: Ansible

More on Jinja2, Conditionals and Loops