This repository has been archived by the owner on Dec 6, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 1e5b8b0
Showing
2 changed files
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |