i am having somewhat the same problem.
But i dont find any solution to that.
I have to use lookup within a template with jinja2.
address {{ lookup('dig', '({{hosts}}{{domain1}})') }}
Were hosts and domain1 are lists defined in default/main.yml
and will be used in a for loop inside the jinja2 template.
{% for hosts in hostlist1 %}
define host {
host_name {{hosts}}
alias {{hosts}}{{domain1}}
address {{ lookup('dig', '({{hosts}}{{domain1}})') }}
}
{% endfor %}
Problem: lookup ('dig', does only accept the real string. Not the variables.
So i can't use this in this template.
Any ideas how to overcome this problem?
Many thx in advance!
Timo