Jinga2 template and numeric dict names

22 views
Skip to first unread message

Michael Wörz

unread,
Feb 15, 2016, 8:14:17 AM2/15/16
to Ansible Project
Hello, given the following dict i want to access the ipaddr value within a jinja2 template

network:
   nics:
      '0':
         ipaddr: 10.251.66.242
         netmask: 255.255.255.0

none of the following works:

{% data.network.nics.0.ipaddr %}
{% data.network.nics.'0'.ipaddr %}
{% data.network.nics[0].ipaddr %}

If I change -'0'- to -A- in my datasource it works with:
{% data.network.nics.A.ipaddr %}

Any Ideas ?

kind regrads


Brian Coca

unread,
Feb 15, 2016, 12:34:26 PM2/15/16
to ansible...@googlegroups.com
{{  data.network.nics['0'].ipaddr  }} , {% %} is for commands


----------
Brian Coca
Reply all
Reply to author
Forward
0 new messages