Interview Prep/Ansible/Variables, Facts and Templates

A variable contains Jinja that should not be evaluated at definition time, like a string for another system.

AdvancedScenarioVariables, Facts and Templates
Answer

Situation read → Escaping templating.

What I'd do →

prom_label: "{% raw %}{{ $labels.instance }}{% endraw %}"
motd: !unsafe "Welcome {{ user }}"

Why → {% raw %} stops Jinja from evaluating the braces, and !unsafe marks a YAML string as never templated.

Interview tip → Prometheus alert and Grafana templates inside Ansible templates are the classic example.

All Ansible questions Roadmap: Ansible

More on Variables, Facts and Templates