summaryrefslogtreecommitdiffstats
path: root/lib/facter/arp.rb
diff options
context:
space:
mode:
authorJames Turnbull <james@lovedthanlost.net>2011-04-06 04:42:39 +1000
committerJames Turnbull <james@lovedthanlost.net>2011-04-06 04:42:39 +1000
commitd5bec9713ba31746fb4de631ea5afb9a9453e3b2 (patch)
treefa21ff6d2c58c205face5db514f23052f7a1dd97 /lib/facter/arp.rb
parentbfa038de95ef3642dd0c66ad7e662b5b0f189555 (diff)
parent53cd946685fe5790dbbe5b2a3964e6d861bbfdde (diff)
downloadfacter-d5bec9713ba31746fb4de631ea5afb9a9453e3b2.tar.gz
facter-d5bec9713ba31746fb4de631ea5afb9a9453e3b2.tar.xz
facter-d5bec9713ba31746fb4de631ea5afb9a9453e3b2.zip
Merge branch 'tickets/master/6976' into next
* tickets/master/6976: Ensures that ARP facts are returned only on EC2 hosts
Diffstat (limited to 'lib/facter/arp.rb')
-rw-r--r--lib/facter/arp.rb12
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/facter/arp.rb b/lib/facter/arp.rb
index 5035ad0..0a7cf67 100644
--- a/lib/facter/arp.rb
+++ b/lib/facter/arp.rb
@@ -3,14 +3,17 @@ require 'facter/util/ip'
Facter.add(:arp) do
confine :kernel => :linux
setcode do
- arp = []
output = Facter::Util::Resolution.exec('arp -a')
if not output.nil?
+ arp = ""
output.each_line do |s|
- arp.push($1) if s =~ /^\S+\s\S+\s\S+\s(\S+)\s\S+\s\S+\s\S+$/
+ if s =~ /^\S+\s\S+\s\S+\s(\S+)\s\S+\s\S+\s\S+$/
+ arp = $1
+ break # stops on the first match
+ end
end
end
- arp[0]
+ EC2_ARP == arp ? arp : nil
end
end
@@ -18,7 +21,8 @@ Facter::Util::IP.get_interfaces.each do |interface|
Facter.add("arp_" + Facter::Util::IP.alphafy(interface)) do
confine :kernel => :linux
setcode do
- Facter::Util::IP.get_arp_value(interface)
+ arp = Facter::Util::IP.get_arp_value(interface)
+ EC2_ARP == arp ? arp : nil
end
end
end