Reputation: 35
I am trying to use a salt mine to get a list of network interfaces of all the minions with the same os as that of the minion on which the jinja template is rendered.
I am trying something like this:
{% set variable = grains['os'] %}
{% set dict = salt['mine.get'('os:variable','network.interfaces','grain') %}
{% for i in dict : %}
// do stuff here
But the problem is in the above salt will try to match os to the value "variable" not to the actual value of the variable.
Using 'os: {{ variable }}'
doesn't work too since {{ x }}
just prints the value of variable x.
How can I match against the actual os in this case?
Upvotes: 0
Views: 1326
Reputation: 5932
You should try +
to concatenate prefix and variable name:
{% set variable = grains['os'] %}
{% set dict = salt['mine.get']('os:' + variable,'network.interfaces','grain') %}
{% for i in dict : %}
# do stuff
{% endfor %}
Upvotes: 3