There was a post about this earlier IIRC. Jinja2 includes in Ansible are not probably well wired up, please do file a ticket.
--Michael On Fri, Mar 21, 2014 at 3:28 AM, Mike Yumatov <[email protected]> wrote: > Hi > > It seems there is a problem with locals in Jinja2 templates. For example, > this works in vanilla Jinja2 environment, but doesn't work in ansible > environment ("One or more undefined variables: 'publisher' is undefined"): > > {# simplified config.xml.j2 #} > <config> > {% for publisher in item.publishers %} > {% include 'publisher.xml.j2' %} > {% endfor %} > </config> > > {# simplified publisher.xml.j2 #} > <report>{{ publisher.report }}</report> > > In Jinja2 local variables are passed to the new context with 'l_' prefix. > This prefix is stripped in vanilla environment [1], but that is not true in > case of ansible environment [2]. So in the latter case 'publisher' variable > is available in 'publisher.xml.j2' template as 'l_publisher'. > > Is this an intended feature, or should I fill a bug report? > > [1]: > https://github.com/mitsuhiko/jinja2/blob/27ffd01f95cad7740497a32b22e4ef9d29762162/jinja2/runtime.py#L67-L69 > [2]: > https://github.com/ansible/ansible/blob/14499e8bf3ed10f7818ec67e1f865d68e4a2a60b/lib/ansible/utils/template.py#L177-L184 > > -- > You received this message because you are subscribed to the Google Groups > "Ansible Project" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/ansible-project/2001111395386938%40web1m.yandex.ru > . > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAEVJ8QN7v%2Bj%3DqiaaXXEqLyJ28KA4KCi3Str9-_c9q9yU%3Dr%2BKFA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
