Interview Prep/Ansible/Performance, Testing and CI/CD

How would you validate Jinja templates without a real server?

BeginnerScenarioPerformance, Testing and CI/CD
Answer

Situation read → Template testing.

What I'd do → Render with ansible localhost -m template or ansible.builtin.template into /tmp in Molecule, then check the output.

ansible localhost -m ansible.builtin.template \
  -a "src=templates/app.conf.j2 dest=/tmp/app.conf" -e @tests/vars.yml

Run the target tool's own validator (nginx -t) on the rendered file in Molecule.

Why → You catch undefined variables and syntax early.

Interview tip → Keep test vars files in the role's molecule/ folder.

All Ansible questions Roadmap: Ansible

More on Performance, Testing and CI/CD