Created
April 12, 2012 15:58
-
-
Save opennetadmin/2368581 to your computer and use it in GitHub Desktop.
Puppet template to calculate the base subnet IP from an IP/MASK input
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<% | |
# This portion simply calculates the baseip from the ip/mask | |
baseip="" | |
addr_parts = scope.lookupvar("ipaddress").split('.') | |
mask_parts = scope.lookupvar("netmask").split('.') | |
addr_parts.zip((0..addr_parts.size).to_a).map do |n,i| | |
baseip += (n.to_i & mask_parts[i].to_i).to_s + "." | |
end | |
baseip = baseip[0..-2] | |
-%> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment