your original logic won’t work. it will both set the three interface logic once AND the four interface logic twice for each “subnet”
this is because you are looping through the subnets and you can’t match all three ever.
{% set IP1 = salt['pillar.get'](grains['host'] ~ ':IP1') %}
{% set IP2 = salt['pillar.get'](grains['host'] ~ ':IP2') %}
{% set SUBNET1 = IP1.split('.')[0:3]|join('.') %}
{% set SUBNET2 = IP2.split('.')[0:3]|join('.') %}
{% set SUBNETS = [ '192.168.1', '192.168.12', '192.168.72' ] %}
{% if SUBNET1 in SUBNETS %}
# process for a two interface storeserv
{% else %}
# process for a four interface storeserv
{% endif %}
--
You received this message because you are subscribed to the Google Groups "Salt-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to salt-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/salt-users/e0f72efa-641d-4443-ade6-990ee3288c43n%40googlegroups.com.
as you presented each subnet will trigger 3 results
either 1 two interfaces and 2 four interfaces, or 3 four interface
so if you are not getting the three results you have something else blocking the non standard result.
in doesn’t check all three at once. it just checks if item a is in the list b.
The other thing i don’t get. you look to be pulling the ip from pillar.why not pull the ip from the server? or even just check if the server is in a subnet directly?
Here is what I’m talking about in what I wrote vs what you wrote.
root@salt00:/srv/salt/tests# salt-call slsutil.renderer salt://tests/jinja.sls default_renderer=jinja
local:
192.168.1
192.168.1
192.168.72
vs
192.168.72
root@salt00:/srv/salt/tests# cat jinja.sls
{% set IP1 = '192.168.72.11' %}
{% set IP2 = '192.168.1.3' %}
{% set SUBNET1 = IP1.split('.')[0:3]|join('.') %}
{% set SUBNET2 = IP2.split('.')[0:3]|join('.') %}
{% set SUBNETS = [ '192.168.1', '192.168.12', '192.168.72' ] %}
{% for SUBNET in SUBNETS %}
{% if SUBNET1 == SUBNET %}
{{SUBNET1}}
{% else %}
{{SUBNET2}}
{% endif %}
{%endfor%}
vs
{% if SUBNET1 in SUBNETS %}
{{SUBNET1}}
{% else %}
{{SUBNET2}}
{% endif %}
To view this discussion on the web visit https://groups.google.com/d/msgid/salt-users/bc90f71e-1bb4-42ce-a463-01b3e8360821n%40googlegroups.com.