network: Added ipv6enabled fact.
This commit is contained in:
parent
2dba5517c0
commit
cb88e1aa0a
1 changed files with 50 additions and 0 deletions
50
network/lib/facter/ipv6enabled.rb
Normal file
50
network/lib/facter/ipv6enabled.rb
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
# Fact: ipv6enabled
|
||||||
|
#
|
||||||
|
# Purpose: Check if system has IPv6 enabled.
|
||||||
|
#
|
||||||
|
# Based on ipaddress6 fact written Cody Herriges <c.a.herriges@gmail.com>.
|
||||||
|
|
||||||
|
def get_address_after_token(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"])
|
||||||
|
|
||||||
|
get_address_after_token(output, 'inet6 addr:')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
Facter.add(:ipv6enabled) do
|
||||||
|
confine :kernel => %w{SunOS}
|
||||||
|
setcode do
|
||||||
|
output = Facter::Util::IP.exec_ifconfig(["-a"])
|
||||||
|
|
||||||
|
get_address_after_token(output, 'inet6')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
Facter.add(:ipv6enabled) do
|
||||||
|
confine :kernel => %w{Darwin FreeBSD OpenBSD}
|
||||||
|
setcode do
|
||||||
|
output = Facter::Util::IP.exec_ifconfig(["-a"])
|
||||||
|
|
||||||
|
get_address_after_token(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")
|
||||||
|
|
||||||
|
get_address_after_token(output, 'Address')
|
||||||
|
end
|
||||||
|
end
|
Loading…
Add table
Reference in a new issue