A template for a config file must not be overwritten by Ansible if an admin edited it, but must exist.
IntermediateScenarioVariables, Facts and Templates
Answer
Situation read → Seed once, never clobber.
What I'd do →
- ansible.builtin.template:
src: app.conf.j2
dest: /etc/app/app.conf
force: false
Why → With force: false the file is only created if it does not exist.
Interview tip → Explain the drift trade-off: this is intentional for admin-owned files; otherwise own the file fully.
More on Variables, Facts and Templates
A variable you set in `group_vars` is being overridden and you do not know where. How do you find the source?IntermediateYou need different values per environment without copying playbooks.BeginnerYou must render an Nginx config with one `server` block per site from a list.IntermediateA template needs the IPs of all hosts in the `db` group, for example for a replication config.IntermediateNothing should be rendered unless a mandatory variable is supplied.BeginnerPer-host values, like `server_id` for MySQL, must be unique and stable.Intermediate