facter 1.6.1 → 1.6.2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of facter might be problematic. Click here for more details.
- data/CHANGELOG +31 -0
- data/Rakefile +41 -36
- data/conf/redhat/facter.spec +11 -4
- data/conf/solaris/pkginfo +1 -1
- data/install.rb +286 -286
- data/lib/facter.rb +211 -211
- data/lib/facter/Cfkey.rb +24 -24
- data/lib/facter/application.rb +1 -0
- data/lib/facter/architecture.rb +21 -29
- data/lib/facter/domain.rb +34 -34
- data/lib/facter/facterversion.rb +1 -1
- data/lib/facter/fqdn.rb +8 -8
- data/lib/facter/hardwareisa.rb +2 -2
- data/lib/facter/hardwaremodel.rb +12 -12
- data/lib/facter/hostname.rb +14 -14
- data/lib/facter/id.rb +3 -3
- data/lib/facter/interfaces.rb +13 -13
- data/lib/facter/ipaddress.rb +101 -101
- data/lib/facter/iphostnumber.rb +12 -12
- data/lib/facter/kernel.rb +7 -7
- data/lib/facter/kernelmajversion.rb +3 -3
- data/lib/facter/kernelrelease.rb +12 -12
- data/lib/facter/kernelversion.rb +5 -5
- data/lib/facter/lsb.rb +14 -14
- data/lib/facter/lsbmajdistrelease.rb +8 -8
- data/lib/facter/macaddress.rb +44 -44
- data/lib/facter/macosx.rb +21 -21
- data/lib/facter/manufacturer.rb +28 -28
- data/lib/facter/memory.rb +143 -115
- data/lib/facter/netmask.rb +4 -4
- data/lib/facter/network.rb +4 -4
- data/lib/facter/operatingsystem.rb +73 -69
- data/lib/facter/operatingsystemrelease.rb +85 -79
- data/lib/facter/osfamily.rb +31 -0
- data/lib/facter/path.rb +3 -3
- data/lib/facter/physicalprocessorcount.rb +8 -0
- data/lib/facter/processor.rb +91 -72
- data/lib/facter/ps.rb +3 -3
- data/lib/facter/puppetversion.rb +7 -7
- data/lib/facter/rubysitedir.rb +5 -5
- data/lib/facter/rubyversion.rb +1 -1
- data/lib/facter/ssh.rb +16 -16
- data/lib/facter/timezone.rb +3 -3
- data/lib/facter/uniqueid.rb +2 -2
- data/lib/facter/util/collection.rb +96 -96
- data/lib/facter/util/confine.rb +30 -30
- data/lib/facter/util/fact.rb +95 -95
- data/lib/facter/util/ip.rb +173 -173
- data/lib/facter/util/loader.rb +88 -88
- data/lib/facter/util/macosx.rb +46 -46
- data/lib/facter/util/manufacturer.rb +78 -78
- data/lib/facter/util/memory.rb +63 -63
- data/lib/facter/util/netmask.rb +34 -34
- data/lib/facter/util/plist.rb +1 -1
- data/lib/facter/util/plist/generator.rb +177 -177
- data/lib/facter/util/plist/parser.rb +166 -166
- data/lib/facter/util/processor.rb +88 -0
- data/lib/facter/util/resolution.rb +154 -154
- data/lib/facter/util/uptime.rb +42 -42
- data/lib/facter/util/values.rb +9 -9
- data/lib/facter/util/virtual.rb +68 -58
- data/lib/facter/util/vlans.rb +17 -17
- data/lib/facter/virtual.rb +105 -110
- data/lib/facter/vlans.rb +6 -6
- data/spec/fixtures/cpuinfo/amd64dual +57 -0
- data/spec/fixtures/cpuinfo/amd64quad +79 -0
- data/spec/fixtures/cpuinfo/amd64solo +23 -0
- data/spec/fixtures/cpuinfo/amd64tri +86 -0
- data/spec/fixtures/cpuinfo/bbg3-armel +12 -0
- data/spec/fixtures/cpuinfo/beaglexm-armel +12 -0
- data/spec/fixtures/cpuinfo/panda-armel +17 -0
- data/spec/fixtures/cpuinfo/ppc64 +19 -0
- data/spec/fixtures/cpuinfo/sparc +10 -0
- data/spec/fixtures/processorcount/solaris-sparc-kstat-cpu-info +1216 -0
- data/spec/fixtures/processorcount/solaris-x86_64-kstat-cpu-info +225 -0
- data/spec/integration/facter_spec.rb +18 -18
- data/spec/spec_helper.rb +10 -1
- data/spec/unit/architecture_spec.rb +54 -0
- data/spec/unit/domain_spec.rb +23 -0
- data/spec/unit/memory_spec.rb +78 -1
- data/spec/unit/physicalprocessorcount_spec.rb +41 -35
- data/spec/unit/processor_spec.rb +183 -2
- data/spec/unit/util/processor_spec.rb +62 -0
- data/spec/unit/util/uptime_spec.rb +4 -4
- data/spec/unit/util/virtual_spec.rb +26 -5
- data/spec/unit/virtual_spec.rb +47 -2
- data/spec/watchr.rb +125 -0
- metadata +20 -4
data/lib/facter/application.rb
CHANGED
data/lib/facter/architecture.rb
CHANGED
@@ -12,35 +12,27 @@
|
|
12
12
|
#
|
13
13
|
|
14
14
|
Facter.add(:architecture) do
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
model
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
Facter.add(:architecture) do
|
41
|
-
confine :kernel => :openbsd
|
42
|
-
setcode do
|
43
|
-
architecture = Facter.value(:hardwaremodel)
|
15
|
+
setcode do
|
16
|
+
model = Facter.value(:hardwaremodel)
|
17
|
+
case model
|
18
|
+
# most linuxen use "x86_64"
|
19
|
+
when "x86_64"
|
20
|
+
case Facter.value(:operatingsystem)
|
21
|
+
when "Debian", "Gentoo", "GNU/kFreeBSD", "Ubuntu"
|
22
|
+
"amd64"
|
23
|
+
else
|
24
|
+
model
|
25
|
+
end
|
26
|
+
when /(i[3456]86|pentium)/
|
27
|
+
case Facter.value(:operatingsystem)
|
28
|
+
when "Gentoo"
|
29
|
+
"x86"
|
30
|
+
else
|
31
|
+
"i386"
|
32
|
+
end
|
33
|
+
else
|
34
|
+
model
|
44
35
|
end
|
36
|
+
end
|
45
37
|
end
|
46
38
|
|
data/lib/facter/domain.rb
CHANGED
@@ -19,45 +19,45 @@
|
|
19
19
|
#
|
20
20
|
|
21
21
|
Facter.add(:domain) do
|
22
|
-
|
23
|
-
|
24
|
-
|
22
|
+
setcode do
|
23
|
+
# Get the domain from various sources; the order of these
|
24
|
+
# steps is important
|
25
25
|
|
26
|
-
|
27
|
-
|
26
|
+
if name = Facter::Util::Resolution.exec('hostname') and
|
27
|
+
name =~ /.*?\.(.+$)/
|
28
28
|
|
29
|
-
|
30
|
-
|
31
|
-
|
29
|
+
$1
|
30
|
+
elsif domain = Facter::Util::Resolution.exec('dnsdomainname') and
|
31
|
+
domain =~ /.+\..+/
|
32
32
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
end
|
33
|
+
domain
|
34
|
+
elsif FileTest.exists?("/etc/resolv.conf")
|
35
|
+
domain = nil
|
36
|
+
search = nil
|
37
|
+
File.open("/etc/resolv.conf") { |file|
|
38
|
+
file.each { |line|
|
39
|
+
if line =~ /^\s*domain\s+(\S+)/
|
40
|
+
domain = $1
|
41
|
+
elsif line =~ /^\s*search\s+(\S+)/
|
42
|
+
search = $1
|
43
|
+
end
|
44
|
+
}
|
45
|
+
}
|
46
|
+
next domain if domain
|
47
|
+
next search if search
|
49
48
|
end
|
49
|
+
end
|
50
50
|
end
|
51
51
|
|
52
52
|
Facter.add(:domain) do
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
53
|
+
confine :kernel => :windows
|
54
|
+
setcode do
|
55
|
+
require 'facter/util/wmi'
|
56
|
+
domain = ""
|
57
|
+
Facter::Util::WMI.execquery("select DNSDomain from Win32_NetworkAdapterConfiguration where IPEnabled = True").each { |nic|
|
58
|
+
domain = nic.DNSDomain
|
59
|
+
break
|
60
|
+
}
|
61
|
+
domain
|
62
|
+
end
|
63
63
|
end
|
data/lib/facter/facterversion.rb
CHANGED
data/lib/facter/fqdn.rb
CHANGED
@@ -10,13 +10,13 @@
|
|
10
10
|
#
|
11
11
|
|
12
12
|
Facter.add(:fqdn) do
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
end
|
13
|
+
setcode do
|
14
|
+
host = Facter.value(:hostname)
|
15
|
+
domain = Facter.value(:domain)
|
16
|
+
if host and domain
|
17
|
+
[host, domain].join(".")
|
18
|
+
else
|
19
|
+
nil
|
21
20
|
end
|
21
|
+
end
|
22
22
|
end
|
data/lib/facter/hardwareisa.rb
CHANGED
@@ -11,6 +11,6 @@
|
|
11
11
|
#
|
12
12
|
|
13
13
|
Facter.add(:hardwareisa) do
|
14
|
-
|
15
|
-
|
14
|
+
setcode 'uname -p'
|
15
|
+
confine :operatingsystem => %w{Solaris Linux Fedora RedHat CentOS Scientific SLC SuSE SLES Debian Ubuntu Gentoo FreeBSD OpenBSD NetBSD DragonFly OEL OracleLinux OVS GNU/kFreeBSD}
|
16
16
|
end
|
data/lib/facter/hardwaremodel.rb
CHANGED
@@ -12,23 +12,23 @@
|
|
12
12
|
#
|
13
13
|
|
14
14
|
Facter.add(:hardwaremodel) do
|
15
|
-
|
15
|
+
setcode 'uname -m'
|
16
16
|
end
|
17
17
|
|
18
18
|
Facter.add(:hardwaremodel) do
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
end
|
19
|
+
confine :operatingsystem => :aix
|
20
|
+
setcode do
|
21
|
+
model = Facter::Util::Resolution.exec('lsattr -El sys0 -a modelname')
|
22
|
+
if model =~ /modelname\s(\S+)\s/
|
23
|
+
$1
|
25
24
|
end
|
25
|
+
end
|
26
26
|
end
|
27
27
|
|
28
28
|
Facter.add(:hardwaremodel) do
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
29
|
+
confine :operatingsystem => :windows
|
30
|
+
setcode do
|
31
|
+
require 'rbconfig'
|
32
|
+
Config::CONFIG['host_cpu']
|
33
|
+
end
|
34
34
|
end
|
data/lib/facter/hostname.rb
CHANGED
@@ -12,22 +12,22 @@
|
|
12
12
|
#
|
13
13
|
|
14
14
|
Facter.add(:hostname, :ldapname => "cn") do
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
end
|
24
|
-
hostname
|
15
|
+
setcode do
|
16
|
+
hostname = nil
|
17
|
+
if name = Facter::Util::Resolution.exec('hostname')
|
18
|
+
if name =~ /(.*?)\./
|
19
|
+
hostname = $1
|
20
|
+
else
|
21
|
+
hostname = name
|
22
|
+
end
|
25
23
|
end
|
24
|
+
hostname
|
25
|
+
end
|
26
26
|
end
|
27
27
|
|
28
28
|
Facter.add(:hostname) do
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
29
|
+
confine :kernel => :darwin, :kernelrelease => "R7"
|
30
|
+
setcode do
|
31
|
+
Facter::Util::Resolution.exec('/usr/sbin/scutil --get LocalHostName')
|
32
|
+
end
|
33
33
|
end
|
data/lib/facter/id.rb
CHANGED
data/lib/facter/interfaces.rb
CHANGED
@@ -20,22 +20,22 @@ require 'facter/util/ip'
|
|
20
20
|
# is missing.
|
21
21
|
|
22
22
|
Facter.add(:interfaces) do
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
23
|
+
confine :kernel => Facter::Util::IP.supported_platforms
|
24
|
+
setcode do
|
25
|
+
Facter::Util::IP.get_interfaces.collect { |iface| Facter::Util::IP.alphafy(iface) }.join(",")
|
26
|
+
end
|
27
27
|
end
|
28
28
|
|
29
29
|
Facter::Util::IP.get_interfaces.each do |interface|
|
30
30
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
end
|
31
|
+
# Make a fact for each detail of each interface. Yay.
|
32
|
+
# There's no point in confining these facts, since we wouldn't be able to create
|
33
|
+
# them if we weren't running on a supported platform.
|
34
|
+
%w{ipaddress ipaddress6 macaddress netmask}.each do |label|
|
35
|
+
Facter.add(label + "_" + Facter::Util::IP.alphafy(interface)) do
|
36
|
+
setcode do
|
37
|
+
Facter::Util::IP.get_interface_value(interface, label)
|
38
|
+
end
|
40
39
|
end
|
40
|
+
end
|
41
41
|
end
|
data/lib/facter/ipaddress.rb
CHANGED
@@ -23,138 +23,138 @@
|
|
23
23
|
#
|
24
24
|
|
25
25
|
Facter.add(:ipaddress) do
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
26
|
+
confine :kernel => :linux
|
27
|
+
setcode do
|
28
|
+
ip = nil
|
29
|
+
output = %x{/sbin/ifconfig}
|
30
30
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
31
|
+
output.split(/^\S/).each { |str|
|
32
|
+
if str =~ /inet addr:([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/
|
33
|
+
tmp = $1
|
34
|
+
unless tmp =~ /^127\./
|
35
|
+
ip = tmp
|
36
|
+
break
|
37
|
+
end
|
38
|
+
end
|
39
|
+
}
|
40
40
|
|
41
|
-
|
42
|
-
|
41
|
+
ip
|
42
|
+
end
|
43
43
|
end
|
44
44
|
|
45
45
|
Facter.add(:ipaddress) do
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
46
|
+
confine :kernel => %w{FreeBSD OpenBSD Darwin DragonFly}
|
47
|
+
setcode do
|
48
|
+
ip = nil
|
49
|
+
output = %x{/sbin/ifconfig}
|
50
50
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
51
|
+
output.split(/^\S/).each { |str|
|
52
|
+
if str =~ /inet ([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/
|
53
|
+
tmp = $1
|
54
|
+
unless tmp =~ /^127\./
|
55
|
+
ip = tmp
|
56
|
+
break
|
57
|
+
end
|
58
|
+
end
|
59
|
+
}
|
60
60
|
|
61
|
-
|
62
|
-
|
61
|
+
ip
|
62
|
+
end
|
63
63
|
end
|
64
64
|
|
65
65
|
Facter.add(:ipaddress) do
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
66
|
+
confine :kernel => %w{NetBSD SunOS}
|
67
|
+
setcode do
|
68
|
+
ip = nil
|
69
|
+
output = %x{/sbin/ifconfig -a}
|
70
70
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
71
|
+
output.split(/^\S/).each { |str|
|
72
|
+
if str =~ /inet ([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/
|
73
|
+
tmp = $1
|
74
|
+
unless tmp =~ /^127\./ or tmp == "0.0.0.0"
|
75
|
+
ip = tmp
|
76
|
+
break
|
77
|
+
end
|
78
|
+
end
|
79
|
+
}
|
80
80
|
|
81
|
-
|
82
|
-
|
81
|
+
ip
|
82
|
+
end
|
83
83
|
end
|
84
84
|
|
85
85
|
Facter.add(:ipaddress) do
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
86
|
+
confine :kernel => %w{AIX}
|
87
|
+
setcode do
|
88
|
+
ip = nil
|
89
|
+
output = %x{/usr/sbin/ifconfig -a}
|
90
90
|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
91
|
+
output.split(/^\S/).each { |str|
|
92
|
+
if str =~ /inet ([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/
|
93
|
+
tmp = $1
|
94
|
+
unless tmp =~ /^127\./
|
95
|
+
ip = tmp
|
96
|
+
break
|
97
|
+
end
|
98
|
+
end
|
99
|
+
}
|
100
100
|
|
101
|
-
|
102
|
-
|
101
|
+
ip
|
102
|
+
end
|
103
103
|
end
|
104
104
|
|
105
105
|
Facter.add(:ipaddress) do
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
106
|
+
confine :kernel => %w{windows}
|
107
|
+
setcode do
|
108
|
+
require 'socket'
|
109
|
+
IPSocket.getaddress(Socket.gethostname)
|
110
|
+
end
|
111
111
|
end
|
112
112
|
|
113
113
|
Facter.add(:ipaddress, :ldapname => "iphostnumber", :timeout => 2) do
|
114
|
-
|
114
|
+
setcode do
|
115
|
+
if Facter.value(:kernel) == 'windows'
|
116
|
+
require 'win32/resolv'
|
117
|
+
else
|
118
|
+
require 'resolv'
|
119
|
+
end
|
120
|
+
|
121
|
+
begin
|
122
|
+
if hostname = Facter.value(:hostname)
|
115
123
|
if Facter.value(:kernel) == 'windows'
|
116
|
-
|
124
|
+
ip = Win32::Resolv.get_resolv_info.last[0]
|
117
125
|
else
|
118
|
-
|
126
|
+
ip = Resolv.getaddress(hostname)
|
119
127
|
end
|
120
|
-
|
121
|
-
|
122
|
-
if hostname = Facter.value(:hostname)
|
123
|
-
if Facter.value(:kernel) == 'windows'
|
124
|
-
ip = Win32::Resolv.get_resolv_info.last[0]
|
125
|
-
else
|
126
|
-
ip = Resolv.getaddress(hostname)
|
127
|
-
end
|
128
|
-
unless ip == "127.0.0.1"
|
129
|
-
ip
|
130
|
-
end
|
131
|
-
else
|
132
|
-
nil
|
133
|
-
end
|
134
|
-
rescue Resolv::ResolvError
|
135
|
-
nil
|
136
|
-
rescue NoMethodError # i think this is a bug in resolv.rb?
|
137
|
-
nil
|
128
|
+
unless ip == "127.0.0.1"
|
129
|
+
ip
|
138
130
|
end
|
131
|
+
else
|
132
|
+
nil
|
133
|
+
end
|
134
|
+
rescue Resolv::ResolvError
|
135
|
+
nil
|
136
|
+
rescue NoMethodError # i think this is a bug in resolv.rb?
|
137
|
+
nil
|
139
138
|
end
|
139
|
+
end
|
140
140
|
end
|
141
141
|
|
142
142
|
Facter.add(:ipaddress, :timeout => 2) do
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
end
|
153
|
-
else
|
154
|
-
nil
|
155
|
-
end
|
156
|
-
else
|
157
|
-
nil
|
143
|
+
setcode do
|
144
|
+
if hostname = Facter.value(:hostname)
|
145
|
+
# we need Hostname to exist for this to work
|
146
|
+
host = nil
|
147
|
+
if host = Facter::Util::Resolution.exec("host #{hostname}")
|
148
|
+
list = host.chomp.split(/\s/)
|
149
|
+
if defined? list[-1] and
|
150
|
+
list[-1] =~ /[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+/
|
151
|
+
list[-1]
|
158
152
|
end
|
153
|
+
else
|
154
|
+
nil
|
155
|
+
end
|
156
|
+
else
|
157
|
+
nil
|
159
158
|
end
|
159
|
+
end
|
160
160
|
end
|