salt
salt copied to clipboard
General question about targeting partial IP address
I am trying to use some jinja logic like so...
{% if grains["ipv4"] == "10.171.*" %}
do stuff
{% endif %}
but this does not work, so how can I go about achieving this?
Thanks,
Greg UWHealth
@LaughHammers The first thing that comes to mind is this:
{% if grains["ipv4"].startswith("10.171") %}
do stuff
{% endif %}
If this doesn't work then you'll probably want to look into using a custom module. An example of this can be found here: https://groups.google.com/forum/#!topic/salt-users/EUbnCGlroAA
@dwoz This is what ended up working for me.
{% if salt.network.ip_in_subnet( salt'network.ip_addrs' , '10.171.0.0/16' ) %}