Reputation: 401
I am trying to set value in j2 template in ansible. But the variable contains index inside it. For example:
lb_url: {{ lbip_{{index }}_url }}
But the above format doesn't work. What is the right format to support this?
Upvotes: 2
Views: 1641
Reputation: 67959
Try lookup
vars
. See Other operators
and the comment on + operator
.
lb_url: "{{ lookup('vars', 'lbip_' ~ index ~ '_url') }}"
Upvotes: 1