diff options
Diffstat (limited to 'puppet/modules/stdlib/lib/facter/netmask_cidr_interface.rb')
m--------- | puppet/modules/stdlib | 0 | ||||
-rw-r--r-- | puppet/modules/stdlib/lib/facter/netmask_cidr_interface.rb | 22 |
2 files changed, 22 insertions, 0 deletions
diff --git a/puppet/modules/stdlib b/puppet/modules/stdlib deleted file mode 160000 -Subproject 71123634744b9fe2ec7d6a3e38e9789fd84801e diff --git a/puppet/modules/stdlib/lib/facter/netmask_cidr_interface.rb b/puppet/modules/stdlib/lib/facter/netmask_cidr_interface.rb new file mode 100644 index 00000000..d628d08c --- /dev/null +++ b/puppet/modules/stdlib/lib/facter/netmask_cidr_interface.rb @@ -0,0 +1,22 @@ +# adds netmask facts for each interface in cidr notation +# i.e.: +# ... +# netmask_cidr_eth2 => 24 +# netmask_cidr_lo => 8 +# netmask_cidr_tun0 => 32 +# netmask_cidr_virbr0 => 24 +# ... + +require 'facter/util/ip' + +Facter::Util::IP.get_interfaces.each do |interface| + netmask = Facter.value("netmask_#{interface}") + if netmask != nil + Facter.add("netmask_cidr_" + interface ) do + setcode do + cidr_netmask=IPAddr.new(netmask).to_i.to_s(2).count("1") + cidr_netmask + end + end + end +end |