One of my roles uses a template, which has an {% import … %} statement to include data from another template.
I’d like this other template to be outside of the role’s “templates” directory, since it will be shared by multiple roles.
If I try including a relative path:
{% import …/…/…/foo.j2 as foo with context %}
it fails with the error “Cannot find/not allowed to load (include) template”. I think this is because Jinja2 won’t include paths with “…” in them.
But it also fails if I include an absolute path, using playbook_dir:
{% import playbook_dir ~ ‘/foo.j2’ as foo with context %}
Why would that second version fail? Is there another way to do this?
Thanks,
Jacob