On 02/17/2012 12:04 PM, no-re...@cfengine.com wrote: > Forum: CFEngine Help > Subject: Re: Find which nic(s) match with iprange? > Author: zzamboni > Link to topic: https://cfengine.com/forum/read.php?3,24908,24914#msg-24914 > > Hi Nick, > > I was going to reply with what's below, but then I realized that you are > correct - iprange() doesn't allow you to specify which IP address to check, > it just checks all addresses of the current host. Maybe open a ticket?
Yeah, I found your example extremely useful and bookmarked it when I was reading the pre-release, thats how I knew how to use the regcmp to find the interface that had an ip that matched the ipregex. My thought was to try to use the iprange function instead but that wouldnt work because it just returns true if there is any ip on the system in the range, I don't see any way to restrict the iprange function to only look at a specific value. I have it solved for the moment but I consider the solution "ugly" I used your example as a base and modified it to take two parameters one being a the ipregex and one being my array with settings. I think its kind of ugly because I think that ip regex is harder to read and I try to hide regexes from the top layers as much as makes sense. For the curious the bundle is for setting routes and here is an example of the data structure I am using. classes: "blue_net" expression => iprange("192.168.35.0/24"); vars: "blue_net":: "blue_routes[192.168.5.0/24]" string => "192.168.5.0/24 via 192.168.35.254", comment => "The blue network needs to be able to talk to the 5 net for some operational things like backups, shell access etc .."; If anyone is interested in a complete example I can try and post one later, but this shows the data I have in the array, and I wanted to not have to pass a regex as well. I could replace the index with a regex but in addition to that being harder to read I use that specific value for removing any conflicting routes as well so then my issue would be getting the value of the subnet which I suppose I could split out of the string to get. .... just rambling now thinking out loud. -- Nick Anderson <n...@cmdln.org> _______________________________________________ Help-cfengine mailing list Help-cfengine@cfengine.org https://cfengine.org/mailman/listinfo/help-cfengine