network: Rewrote ipv6enabled fact to use ping instead of ifconfig.
This commit is contained in:
parent
d126f4a804
commit
2c0daef37b
1 changed files with 6 additions and 41 deletions
|
@ -2,49 +2,14 @@
|
|||
#
|
||||
# Purpose: Check if system has IPv6 enabled.
|
||||
#
|
||||
# Based on ipaddress6 fact written Cody Herriges <c.a.herriges@gmail.com>.
|
||||
|
||||
def check_for_ipv6_address(output, token)
|
||||
ret = false
|
||||
output.scan(/#{token} ((?>[0-9,a-f,A-F]*\:{1,2})+[0-9,a-f,A-F]{0,4})/).each do |match|
|
||||
ret = true
|
||||
break
|
||||
end
|
||||
ret
|
||||
end
|
||||
|
||||
Facter.add(:ipv6enabled) do
|
||||
confine :kernel => :linux
|
||||
setcode do
|
||||
output = Facter::Util::IP.exec_ifconfig(["2>/dev/null"])
|
||||
|
||||
check_for_ipv6_address(output, 'inet6 addr:')
|
||||
out = Facter::Util::Resolution.exec('ping6 -c 1 ::1 2> /dev/null | egrep " [0\.]*% packet loss"')
|
||||
if out
|
||||
"true"
|
||||
else
|
||||
"false"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Facter.add(:ipv6enabled) do
|
||||
confine :kernel => %w{SunOS}
|
||||
setcode do
|
||||
output = Facter::Util::IP.exec_ifconfig(["-a"])
|
||||
|
||||
check_for_ipv6_address(output, 'inet6')
|
||||
end
|
||||
end
|
||||
|
||||
Facter.add(:ipv6enabled) do
|
||||
confine :kernel => %w{Darwin FreeBSD OpenBSD}
|
||||
setcode do
|
||||
output = Facter::Util::IP.exec_ifconfig(["-a"])
|
||||
|
||||
check_for_ipv6_address(output, 'inet6')
|
||||
end
|
||||
end
|
||||
|
||||
Facter.add(:ipv6enabled) do
|
||||
confine :kernel => :windows
|
||||
setcode do
|
||||
output = Facter::Util::Resolution.exec("#{ENV['SYSTEMROOT']}/system32/netsh.exe interface ipv6 show address level=verbose")
|
||||
|
||||
check_for_ipv6_address(output, 'Address')
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue