0

I need to resolve variables in my jinja2 templates with variables defined in an inventory file NOT in global definition level:

---
all:
  hosts:
    default:
      ...
  vars:
    objects:
      obj1:
        some_var: "foo"
      obj2:
        some_var: "bar"
      obj3:
        some_var: "baz"

Typical template obj1.j2:

...
DEFINE {{ some_var }}
...

Help me to figure out how to put variables into vars block please.

  name: "Templates resolution"
  template:
    src: "{{ item }}.j2"
    dest: "/tmp/{{ item }}"
    vars:
      <some_var should be here>
  with_items: "{{ template_names }}"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.