Interview Prep/Ansible/Variables, Facts and Templates

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.

All Ansible questions Roadmap: Ansible

More on Variables, Facts and Templates