Skip to content
This repository has been archived by the owner on Dec 6, 2022. It is now read-only.

Commit

Permalink
initial import
Browse files Browse the repository at this point in the history
  • Loading branch information
ripienaar committed May 23, 2010
0 parents commit 1e5b8b0
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
19 changes: 19 additions & 0 deletions redhat-hwaddr/README
@@ -0,0 +1,19 @@
A fact that will find all interfaces in /etc/sysconfig/network-scripts
and pull out the HWADDR from each.

You'd use this if you have bonded nics and need to know the real
MAC addresses, since bonding will change the MAC on the network
cards at runtime.

# facter -p|egrep '(hwad|mac)'
hwaddr_eth0 => 00:14:5E:33:62:0A
hwaddr_eth1 => 00:14:5E:33:62:0B
macaddress => 00:14:5E:33:62:0A
macaddress_bond0 => 00:14:5E:33:62:0A
macaddress_bond0:1 => 00:14:5E:33:62:0A
macaddress_eth0 => 00:14:5E:33:62:0A
macaddress_eth1 => 00:14:5E:33:62:0A

This example shows that the standard macaddress_* facts do not cope
well with bonding, but this fact will add new facts that sets the
real macs
17 changes: 17 additions & 0 deletions redhat-hwaddr/hwaddr.rb
@@ -0,0 +1,17 @@
require 'find'

if File.exists?("/etc/sysconfig/network-scripts")
Find.find("/etc/sysconfig/network-scripts") do |path|
if (path =~ /ifcfg-(.+)$/)
interface = $1
File.open(path).each do |line|
if line =~ /^HWADDR=(.+)$/
mac = $1
Facter.add("hwaddr_#{interface}") do
setcode { mac }
end
end
end
end
end
end

0 comments on commit 1e5b8b0

Please sign in to comment.