Advertisement
Guest User

Untitled

a guest
Sep 4th, 2012
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.40 KB | None | 0 0
  1. # Fact: cidr
  2. # Find the CIDR notation for all the network interfaces
  3.  
  4. require 'facter/util/ip'
  5.  
  6. Facter::Util::IP.get_interfaces.each do |interface|
  7.   Facter.add("cidr_" + (interface)) do
  8.     setcode do
  9.       Facter::Util::Resolution.exec("/sbin/ip route show | grep `/sbin/ifconfig #{interface} | awk '/inet addr:/{print $2}' | cut -d':' -f2` | cut -d\/ -f2 | cut -d' ' -f1").chomp
  10.     end
  11.   end
  12. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement