Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Is it possible to assign vars to template, but in the template scope only?

Idea is something like that..


template: src=/mytemplates/file1.j2 dest=..
- vars
  - foo: {{ global_var_foo_1 }}
  - bar: {{ global_var_bar_1 }}

template: src=/mytemplates/file2.j2 dest=..
- vars
  - foo: {{ global_var_foo_2 }}
  - bar: {{ global_var_bar_2 }}

So in the two templates above I can use {{ foo }} and {{ bar }} directly, but not mixing up them with global variables

share|improve this question
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.