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?
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?
Try lookup vars. See Other operators and the comment on + operator.
lb_url: "{{ lookup('vars', 'lbip_' ~ index ~ '_url') }}"