Interview Prep/Ansible/Variables, Facts and Templates

Passwords in a template must not be world readable.

BeginnerScenarioVariables, Facts and Templates
Answer

Situation read → File permission hygiene.

What I'd do →

- ansible.builtin.template:
    src: db.env.j2
    dest: /etc/app/db.env
    owner: app
    group: app
    mode: "0600"

Why → Quote the mode as a string; an unquoted 0600 is read by YAML as octal in some contexts and as an int in others.

Interview tip → Always set mode explicitly on secrets.

All Ansible questions Roadmap: Ansible

More on Variables, Facts and Templates