facter 1.6.18 → 1.7.0.rc1
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/Gemfile +23 -8
- data/bin/facter +4 -1
- data/ext/build_defaults.yaml +1 -1
- data/ext/debian/changelog.erb +4 -22
- data/ext/debian/control +2 -2
- data/ext/project_data.yaml +1 -1
- data/ext/redhat/facter.spec.erb +10 -9
- data/install.rb +27 -53
- data/lib/facter.rb +23 -5
- data/lib/facter/application.rb +21 -0
- data/lib/facter/blockdevices.rb +105 -0
- data/lib/facter/domain.rb +19 -7
- data/lib/facter/filesystems.rb +38 -0
- data/lib/facter/hardwaremodel.rb +3 -2
- data/lib/facter/ipaddress6.rb +1 -2
- data/lib/facter/kernelrelease.rb +10 -2
- data/lib/facter/ldom.rb +47 -0
- data/lib/facter/macaddress.rb +1 -1
- data/lib/facter/manufacturer.rb +7 -1
- data/lib/facter/memory.rb +58 -160
- data/lib/facter/operatingsystem.rb +17 -2
- data/lib/facter/operatingsystemmajrelease.rb +33 -0
- data/lib/facter/operatingsystemrelease.rb +88 -37
- data/lib/facter/osfamily.rb +6 -2
- data/lib/facter/processor.rb +2 -2
- data/lib/facter/ps.rb +5 -0
- data/lib/facter/ssh.rb +50 -12
- data/lib/facter/util/cfpropertylist.rb +6 -0
- data/lib/facter/util/cfpropertylist/LICENSE +19 -0
- data/lib/facter/util/cfpropertylist/README +44 -0
- data/lib/facter/util/cfpropertylist/Rakefile +44 -0
- data/lib/facter/util/cfpropertylist/THANKS +7 -0
- data/lib/facter/util/cfpropertylist/lib/cfpropertylist.rb +6 -0
- data/lib/facter/util/cfpropertylist/lib/rbBinaryCFPropertyList.rb +562 -0
- data/lib/facter/util/cfpropertylist/lib/rbCFPlistError.rb +26 -0
- data/lib/facter/util/cfpropertylist/lib/rbCFPropertyList.rb +402 -0
- data/lib/facter/util/cfpropertylist/lib/rbCFTypes.rb +244 -0
- data/lib/facter/util/cfpropertylist/lib/rbLibXMLParser.rb +135 -0
- data/lib/facter/util/cfpropertylist/lib/rbNokogiriParser.rb +140 -0
- data/lib/facter/util/cfpropertylist/lib/rbREXMLParser.rb +136 -0
- data/lib/facter/util/collection.rb +36 -14
- data/lib/facter/util/composite_loader.rb +12 -0
- data/lib/facter/util/config.rb +36 -0
- data/lib/facter/util/confine.rb +1 -6
- data/lib/facter/util/directory_loader.rb +83 -0
- data/lib/facter/util/fact.rb +49 -42
- data/lib/facter/util/file_read.rb +32 -0
- data/lib/facter/util/ip.rb +2 -9
- data/lib/facter/util/loader.rb +16 -2
- data/lib/facter/util/macosx.rb +15 -2
- data/lib/facter/util/memory.rb +154 -27
- data/lib/facter/util/nothing_loader.rb +15 -0
- data/lib/facter/util/parser.rb +141 -0
- data/lib/facter/util/processor.rb +27 -35
- data/lib/facter/util/resolution.rb +97 -26
- data/lib/facter/util/solaris_zones.rb +153 -0
- data/lib/facter/util/virtual.rb +32 -3
- data/lib/facter/version.rb +72 -2
- data/lib/facter/virtual.rb +56 -3
- data/lib/facter/zfs_version.rb +10 -0
- data/lib/facter/zonename.rb +6 -0
- data/lib/facter/zones.rb +17 -0
- data/lib/facter/zpool_version.rb +10 -0
- data/spec/fixtures/ifconfig/ifconfig_net_tools_1.60.txt +19 -0
- data/spec/fixtures/ifconfig/ifconfig_ubuntu_1204.txt +16 -0
- data/spec/fixtures/ldom/ldom_v1 +6 -0
- data/spec/fixtures/unit/filesystems/linux +28 -0
- data/spec/fixtures/unit/util/manufacturer/intel_linux_dmidecode +549 -0
- data/spec/fixtures/unit/virtual/sysfs_dmi_entries_raw.txt +0 -0
- data/spec/fixtures/unit/zfs_version/freebsd_8.2 +14 -0
- data/spec/fixtures/unit/zfs_version/freebsd_9.0 +13 -0
- data/spec/fixtures/unit/zfs_version/linux-fuse_0.6.9 +14 -0
- data/spec/fixtures/unit/zfs_version/solaris_10 +10 -0
- data/spec/fixtures/unit/zfs_version/solaris_11 +12 -0
- data/spec/fixtures/unit/zpool_version/freebsd_8.2 +26 -0
- data/spec/fixtures/unit/zpool_version/freebsd_9.0 +38 -0
- data/spec/fixtures/unit/zpool_version/linux-fuse_0.6.9 +35 -0
- data/spec/fixtures/unit/zpool_version/solaris_10 +31 -0
- data/spec/fixtures/unit/zpool_version/solaris_11 +43 -0
- data/spec/integration/facter_spec.rb +12 -0
- data/spec/spec_helper.rb +9 -0
- data/spec/unit/architecture_spec.rb +1 -1
- data/spec/unit/blockdevices_spec.rb +109 -0
- data/spec/unit/domain_spec.rb +189 -81
- data/spec/unit/ec2_spec.rb +15 -8
- data/spec/unit/filesystems_spec.rb +50 -0
- data/spec/unit/hardwaremodel_spec.rb +8 -1
- data/spec/unit/id_spec.rb +6 -5
- data/spec/unit/ipaddress6_spec.rb +14 -2
- data/spec/unit/ipaddress_spec.rb +1 -1
- data/spec/unit/kernel_spec.rb +24 -0
- data/spec/unit/kernelmajversion_spec.rb +17 -0
- data/spec/unit/kernelrelease_spec.rb +53 -0
- data/spec/unit/kernelversion_spec.rb +32 -0
- data/spec/unit/ldom_spec.rb +74 -0
- data/spec/unit/macaddress_spec.rb +3 -1
- data/spec/unit/manufacturer_spec.rb +115 -0
- data/spec/unit/memory_spec.rb +442 -75
- data/spec/unit/operatingsystem_spec.rb +16 -2
- data/spec/unit/operatingsystemmajrelease_spec.rb +16 -0
- data/spec/unit/operatingsystemrelease_spec.rb +110 -1
- data/spec/unit/processor_spec.rb +22 -7
- data/spec/unit/ps_spec.rb +42 -0
- data/spec/unit/ssh_spec.rb +76 -0
- data/spec/unit/util/collection_spec.rb +94 -118
- data/spec/unit/util/config_spec.rb +36 -5
- data/spec/unit/util/confine_spec.rb +31 -43
- data/spec/unit/util/directory_loader_spec.rb +87 -0
- data/spec/unit/util/fact_spec.rb +37 -25
- data/spec/unit/util/file_read_spec.rb +29 -0
- data/spec/unit/util/ip_spec.rb +4 -2
- data/spec/unit/util/loader_spec.rb +102 -45
- data/spec/unit/util/macosx_spec.rb +40 -9
- data/spec/unit/util/manufacturer_spec.rb +12 -1
- data/spec/unit/util/parser_spec.rb +135 -0
- data/spec/unit/util/resolution_spec.rb +136 -4
- data/spec/unit/util/solaris_zones_spec.rb +127 -0
- data/spec/unit/util/virtual_spec.rb +54 -0
- data/spec/unit/version_spec.rb +42 -0
- data/spec/unit/virtual_spec.rb +102 -27
- data/spec/unit/zfs_version_spec.rb +76 -0
- data/spec/unit/zonename_spec.rb +14 -0
- data/spec/unit/zones_spec.rb +55 -0
- data/spec/unit/zpool_version_spec.rb +76 -0
- metadata +113 -11
- data/lib/facter/arp.rb +0 -28
@@ -5,7 +5,7 @@
|
|
5
5
|
# Resolution:
|
6
6
|
# If the kernel is a Linux kernel, check for the existence of a selection of
|
7
7
|
# files in /etc/ to find the specific flavour.
|
8
|
-
# On SunOS based kernels, return Solaris.
|
8
|
+
# On SunOS based kernels, attempt to determine the flavour, otherwise return Solaris.
|
9
9
|
# On systems other than Linux, use the kernel value.
|
10
10
|
#
|
11
11
|
# Caveats:
|
@@ -14,7 +14,16 @@
|
|
14
14
|
Facter.add(:operatingsystem) do
|
15
15
|
confine :kernel => :sunos
|
16
16
|
setcode do
|
17
|
-
|
17
|
+
# Use uname -v because /etc/release can change in zones under SmartOS.
|
18
|
+
# It's apparently not trustworthy enough to rely on for this fact.
|
19
|
+
output = Facter::Util::Resolution.exec('uname -v')
|
20
|
+
if output =~ /^joyent_/
|
21
|
+
"SmartOS"
|
22
|
+
elsif output =~ /^oi_/
|
23
|
+
"OpenIndiana"
|
24
|
+
elsif output =~ /^omnios-/
|
25
|
+
"OmniOS"
|
26
|
+
elsif FileTest.exists?("/etc/debian_version")
|
18
27
|
"Nexenta"
|
19
28
|
else
|
20
29
|
"Solaris"
|
@@ -29,6 +38,8 @@ Facter.add(:operatingsystem) do
|
|
29
38
|
"Ubuntu"
|
30
39
|
elsif FileTest.exists?("/etc/debian_version")
|
31
40
|
"Debian"
|
41
|
+
elsif FileTest.exists?("/etc/openwrt_release")
|
42
|
+
"OpenWrt"
|
32
43
|
elsif FileTest.exists?("/etc/gentoo-release")
|
33
44
|
"Gentoo"
|
34
45
|
elsif FileTest.exists?("/etc/fedora-release")
|
@@ -65,6 +76,8 @@ Facter.add(:operatingsystem) do
|
|
65
76
|
"PSBM"
|
66
77
|
elsif txt =~ /Ascendos/i
|
67
78
|
"Ascendos"
|
79
|
+
elsif txt =~ /^XenServer/i
|
80
|
+
"XenServer"
|
68
81
|
else
|
69
82
|
"RedHat"
|
70
83
|
end
|
@@ -87,6 +100,8 @@ Facter.add(:operatingsystem) do
|
|
87
100
|
"Slackware"
|
88
101
|
elsif FileTest.exists?("/etc/alpine-release")
|
89
102
|
"Alpine"
|
103
|
+
elsif FileTest.exists?("/etc/mageia-release")
|
104
|
+
"Mageia"
|
90
105
|
elsif FileTest.exists?("/etc/system-release")
|
91
106
|
"Amazon"
|
92
107
|
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# Fact: operatingsystemmajrelease
|
2
|
+
#
|
3
|
+
# Purpose: Returns the major release of the operating system.
|
4
|
+
#
|
5
|
+
# Resolution: splits down the operatingsystemrelease fact at decimal point for
|
6
|
+
# osfamily RedHat derivatives and Debian.
|
7
|
+
#
|
8
|
+
# This should be the same as lsbmajdistrelease, but on minimal systems there
|
9
|
+
# are too many dependencies to use LSB
|
10
|
+
#
|
11
|
+
# List of operatingsystems at time of writing:
|
12
|
+
#"Alpine" "Amazon" "Archlinux" "Ascendos" "Bluewhite64" "CentOS" "CloudLinux"
|
13
|
+
#"Debian" "Fedora" "Gentoo" "Mandrake" "Mandriva" "MeeGo" "OEL" "OpenSuSE"
|
14
|
+
#"OracleLinux" "OVS" "PSBM" "RedHat" "Scientific" "Slackware" "Slamd64" "SLC"
|
15
|
+
#"SLED" "SLES" "SuSE" "Ubuntu" "VMWareESX"
|
16
|
+
Facter.add(:operatingsystemmajrelease) do
|
17
|
+
confine :operatingsystem => [
|
18
|
+
:Amazon,
|
19
|
+
:CentOS,
|
20
|
+
:CloudLinux,
|
21
|
+
:Debian,
|
22
|
+
:Fedora,
|
23
|
+
:OEL,
|
24
|
+
:OracleLinux,
|
25
|
+
:OVS,
|
26
|
+
:RedHat,
|
27
|
+
:Scientific,
|
28
|
+
:SLC
|
29
|
+
]
|
30
|
+
setcode do
|
31
|
+
Facter.value('operatingsystemrelease').split('.').first
|
32
|
+
end
|
33
|
+
end
|
@@ -10,17 +10,20 @@
|
|
10
10
|
# information.
|
11
11
|
# On Slackware, parses '/etc/slackware-version'.
|
12
12
|
# On Amazon Linux, returns the 'lsbdistrelease' value.
|
13
|
+
# On Mageia, parses '/etc/mageia-release' for the release version.
|
13
14
|
#
|
14
15
|
# On all remaining systems, returns the 'kernelrelease' value.
|
15
16
|
#
|
16
17
|
# Caveats:
|
17
18
|
#
|
18
19
|
|
20
|
+
require 'facter/util/file_read'
|
21
|
+
|
19
22
|
Facter.add(:operatingsystemrelease) do
|
20
23
|
confine :operatingsystem => %w{CentOS Fedora oel ovs OracleLinux RedHat MeeGo Scientific SLC Ascendos CloudLinux PSBM}
|
21
24
|
setcode do
|
22
25
|
case Facter.value(:operatingsystem)
|
23
|
-
when "CentOS", "RedHat", "Scientific", "SLC", "Ascendos", "CloudLinux", "PSBM"
|
26
|
+
when "CentOS", "RedHat", "Scientific", "SLC", "Ascendos", "CloudLinux", "PSBM", "XenServer"
|
24
27
|
releasefile = "/etc/redhat-release"
|
25
28
|
when "Fedora"
|
26
29
|
releasefile = "/etc/fedora-release"
|
@@ -33,12 +36,13 @@ Facter.add(:operatingsystemrelease) do
|
|
33
36
|
when "OVS", "ovs"
|
34
37
|
releasefile = "/etc/ovs-release"
|
35
38
|
end
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
+
|
40
|
+
if release = Facter::Util::FileRead.read(releasefile)
|
41
|
+
line = release.split("\n").first.chomp
|
42
|
+
if match = /\(Rawhide\)$/.match(line)
|
39
43
|
"Rawhide"
|
40
|
-
elsif
|
41
|
-
|
44
|
+
elsif match = /release (\d[\d.]*)/.match(line)
|
45
|
+
match[1]
|
42
46
|
end
|
43
47
|
end
|
44
48
|
end
|
@@ -47,16 +51,22 @@ end
|
|
47
51
|
Facter.add(:operatingsystemrelease) do
|
48
52
|
confine :operatingsystem => %w{Debian}
|
49
53
|
setcode do
|
50
|
-
release = Facter::Util::
|
54
|
+
if release = Facter::Util::FileRead.read('/etc/debian_version')
|
55
|
+
release.sub!(/\s*$/, '')
|
56
|
+
release
|
57
|
+
end
|
51
58
|
end
|
52
59
|
end
|
53
60
|
|
54
61
|
Facter.add(:operatingsystemrelease) do
|
55
62
|
confine :operatingsystem => %w{Ubuntu}
|
56
63
|
setcode do
|
57
|
-
release = Facter::Util::
|
58
|
-
|
59
|
-
|
64
|
+
if release = Facter::Util::FileRead.read('/etc/issue')
|
65
|
+
if match = release.match(/Ubuntu ((\d+.\d+)(\.(\d+))?)/)
|
66
|
+
# Return only the major and minor version numbers. This behavior must
|
67
|
+
# be preserved for compatibility reasons.
|
68
|
+
match[2]
|
69
|
+
end
|
60
70
|
end
|
61
71
|
end
|
62
72
|
end
|
@@ -64,19 +74,31 @@ end
|
|
64
74
|
Facter.add(:operatingsystemrelease) do
|
65
75
|
confine :operatingsystem => %w{SLES SLED OpenSuSE}
|
66
76
|
setcode do
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
77
|
+
if release = Facter::Util::FileRead.read('/etc/SuSE-release')
|
78
|
+
if match = /^VERSION\s*=\s*(\d+)/.match(release)
|
79
|
+
releasemajor = match[1]
|
80
|
+
if match = /^PATCHLEVEL\s*=\s*(\d+)/.match(release)
|
81
|
+
releaseminor = match[1]
|
82
|
+
elsif match = /^VERSION\s=.*.(\d+)/.match(release)
|
83
|
+
releaseminor = match[1]
|
84
|
+
else
|
85
|
+
releaseminor = "0"
|
86
|
+
end
|
87
|
+
releasemajor + "." + releaseminor
|
74
88
|
else
|
75
|
-
|
89
|
+
"unknown"
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
Facter.add(:operatingsystemrelease) do
|
96
|
+
confine :operatingsystem => %w{OpenWrt}
|
97
|
+
setcode do
|
98
|
+
if release = Facter::Util::FileRead.read('/etc/openwrt_version')
|
99
|
+
if match = /^(\d+\.\d+.*)/.match(release)
|
100
|
+
match[1]
|
76
101
|
end
|
77
|
-
releasemajor + "." + releaseminor
|
78
|
-
else
|
79
|
-
"unknown"
|
80
102
|
end
|
81
103
|
end
|
82
104
|
end
|
@@ -84,9 +106,21 @@ end
|
|
84
106
|
Facter.add(:operatingsystemrelease) do
|
85
107
|
confine :operatingsystem => %w{Slackware}
|
86
108
|
setcode do
|
87
|
-
release = Facter::Util::
|
88
|
-
|
89
|
-
|
109
|
+
if release = Facter::Util::FileRead.read('/etc/slackware-version')
|
110
|
+
if match = /Slackware ([0-9.]+)/.match(release)
|
111
|
+
match[1]
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
Facter.add(:operatingsystemrelease) do
|
118
|
+
confine :operatingsystem => %w{Mageia}
|
119
|
+
setcode do
|
120
|
+
if release = Facter::Util::FileRead.read('/etc/mageia-release')
|
121
|
+
if match = /Mageia release ([0-9.]+)/.match(release)
|
122
|
+
match[1]
|
123
|
+
end
|
90
124
|
end
|
91
125
|
end
|
92
126
|
end
|
@@ -94,11 +128,12 @@ end
|
|
94
128
|
Facter.add(:operatingsystemrelease) do
|
95
129
|
confine :operatingsystem => %w{Bluewhite64}
|
96
130
|
setcode do
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
131
|
+
if release = Facter::Util::FileRead.read('/etc/bluewhite64-version')
|
132
|
+
if match = /^\s*\w+\s+(\d+)\.(\d+)/.match(release)
|
133
|
+
match[1] + "." + match[2]
|
134
|
+
else
|
135
|
+
"unknown"
|
136
|
+
end
|
102
137
|
end
|
103
138
|
end
|
104
139
|
end
|
@@ -107,8 +142,8 @@ Facter.add(:operatingsystemrelease) do
|
|
107
142
|
confine :operatingsystem => %w{VMwareESX}
|
108
143
|
setcode do
|
109
144
|
release = Facter::Util::Resolution.exec('vmware -v')
|
110
|
-
if
|
111
|
-
|
145
|
+
if match = /VMware ESX .*?(\d.*)/.match(release)
|
146
|
+
match[1]
|
112
147
|
end
|
113
148
|
end
|
114
149
|
end
|
@@ -116,11 +151,12 @@ end
|
|
116
151
|
Facter.add(:operatingsystemrelease) do
|
117
152
|
confine :operatingsystem => %w{Slamd64}
|
118
153
|
setcode do
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
154
|
+
if release = Facter::Util::FileRead.read('/etc/slamd64-version')
|
155
|
+
if match = /^\s*\w+\s+(\d+)\.(\d+)/.match(release)
|
156
|
+
match[1] + "." + match[2]
|
157
|
+
else
|
158
|
+
"unknown"
|
159
|
+
end
|
124
160
|
end
|
125
161
|
end
|
126
162
|
end
|
@@ -128,7 +164,10 @@ end
|
|
128
164
|
Facter.add(:operatingsystemrelease) do
|
129
165
|
confine :operatingsystem => :Alpine
|
130
166
|
setcode do
|
131
|
-
|
167
|
+
if release = Facter::Util::FileRead.read('/etc/alpine-release')
|
168
|
+
release.sub!(/\s*$/, '')
|
169
|
+
release
|
170
|
+
end
|
132
171
|
end
|
133
172
|
end
|
134
173
|
|
@@ -137,6 +176,18 @@ Facter.add(:operatingsystemrelease) do
|
|
137
176
|
setcode do Facter[:lsbdistrelease].value end
|
138
177
|
end
|
139
178
|
|
179
|
+
Facter.add(:operatingsystemrelease) do
|
180
|
+
confine :osfamily => :solaris
|
181
|
+
setcode do
|
182
|
+
if release = Facter::Util::FileRead.read('/etc/release')
|
183
|
+
line = release.split("\n").first.chomp
|
184
|
+
if match = /\s+s(\d+)[sx]?(_u\d+)?.*(?:SPARC|X86)/.match(line)
|
185
|
+
match.captures.join('')
|
186
|
+
end
|
187
|
+
end
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
140
191
|
Facter.add(:operatingsystemrelease) do
|
141
192
|
setcode do Facter[:kernelrelease].value end
|
142
193
|
end
|
data/lib/facter/osfamily.rb
CHANGED
@@ -16,14 +16,18 @@ Facter.add(:osfamily) do
|
|
16
16
|
|
17
17
|
setcode do
|
18
18
|
case Facter.value(:operatingsystem)
|
19
|
-
when "RedHat", "Fedora", "CentOS", "Scientific", "SLC", "Ascendos", "CloudLinux", "PSBM", "OracleLinux", "OVS", "OEL"
|
19
|
+
when "RedHat", "Fedora", "CentOS", "Scientific", "SLC", "Ascendos", "CloudLinux", "PSBM", "OracleLinux", "OVS", "OEL", "Amazon", "XenServer"
|
20
20
|
"RedHat"
|
21
21
|
when "Ubuntu", "Debian"
|
22
22
|
"Debian"
|
23
23
|
when "SLES", "SLED", "OpenSuSE", "SuSE"
|
24
24
|
"Suse"
|
25
|
-
when "Solaris", "Nexenta"
|
25
|
+
when "Solaris", "Nexenta", "OmniOS", "OpenIndiana", "SmartOS"
|
26
26
|
"Solaris"
|
27
|
+
when "Gentoo"
|
28
|
+
"Gentoo"
|
29
|
+
when "Archlinux"
|
30
|
+
"Archlinux"
|
27
31
|
else
|
28
32
|
Facter.value("kernel")
|
29
33
|
end
|
data/lib/facter/processor.rb
CHANGED
@@ -147,14 +147,14 @@ if Facter.value(:kernel) == "windows"
|
|
147
147
|
end
|
148
148
|
|
149
149
|
Facter.add("Processor") do
|
150
|
-
confine :kernel => :dragonfly
|
150
|
+
confine :kernel => [:dragonfly,:freebsd]
|
151
151
|
setcode do
|
152
152
|
Facter::Util::Resolution.exec("sysctl -n hw.model")
|
153
153
|
end
|
154
154
|
end
|
155
155
|
|
156
156
|
Facter.add("ProcessorCount") do
|
157
|
-
confine :kernel => :dragonfly
|
157
|
+
confine :kernel => [:dragonfly,:freebsd]
|
158
158
|
setcode do
|
159
159
|
Facter::Util::Resolution.exec("sysctl -n hw.ncpu")
|
160
160
|
end
|
data/lib/facter/ps.rb
CHANGED
@@ -14,6 +14,11 @@ Facter.add(:ps) do
|
|
14
14
|
setcode do 'ps -ef' end
|
15
15
|
end
|
16
16
|
|
17
|
+
Facter.add(:ps) do
|
18
|
+
confine :operatingsystem => :OpenWrt
|
19
|
+
setcode do 'ps www' end
|
20
|
+
end
|
21
|
+
|
17
22
|
Facter.add(:ps) do
|
18
23
|
confine :operatingsystem => %w{FreeBSD NetBSD OpenBSD Darwin DragonFly}
|
19
24
|
setcode do 'ps auxwww' end
|
data/lib/facter/ssh.rb
CHANGED
@@ -11,21 +11,59 @@
|
|
11
11
|
## Facts related to SSH
|
12
12
|
##
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
14
|
+
{"SSHDSAKey" => { :file => "ssh_host_dsa_key.pub", :sshfprrtype => 2 } , "SSHRSAKey" => { :file => "ssh_host_rsa_key.pub", :sshfprrtype => 1 }, "SSHECDSAKey" => { :file => "ssh_host_ecdsa_key.pub", :sshfprrtype => 3 } }.each do |name,key|
|
15
|
+
|
16
|
+
Facter.add(name) do
|
17
|
+
setcode do
|
18
|
+
value = nil
|
19
|
+
|
20
|
+
[ "/etc/ssh",
|
21
|
+
"/usr/local/etc/ssh",
|
22
|
+
"/etc",
|
23
|
+
"/usr/local/etc",
|
24
|
+
"/etc/opt/ssh",
|
25
|
+
].each do |dir|
|
26
|
+
|
27
|
+
filepath = File.join(dir,key[:file])
|
28
|
+
|
20
29
|
if FileTest.file?(filepath)
|
21
30
|
begin
|
22
|
-
|
31
|
+
value = File.read(filepath).chomp.split(/\s+/)[1]
|
32
|
+
break
|
23
33
|
rescue
|
24
34
|
value = nil
|
25
35
|
end
|
26
36
|
end
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
end
|
37
|
+
end
|
38
|
+
|
39
|
+
value
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
Facter.add('SSHFP_' + name[3..-4]) do
|
44
|
+
setcode do
|
45
|
+
ssh = Facter.fact(name).value
|
46
|
+
value = nil
|
47
|
+
|
48
|
+
if ssh && key[:sshfprrtype]
|
49
|
+
begin
|
50
|
+
require 'digest/sha1'
|
51
|
+
require 'base64'
|
52
|
+
digest = Base64.decode64(ssh)
|
53
|
+
value = 'SSHFP ' + key[:sshfprrtype].to_s + ' 1 ' + Digest::SHA1.hexdigest(digest)
|
54
|
+
begin
|
55
|
+
require 'digest/sha2'
|
56
|
+
value += "\nSSHFP " + key[:sshfprrtype].to_s + ' 2 ' + Digest::SHA256.hexdigest(digest)
|
57
|
+
rescue
|
58
|
+
end
|
59
|
+
rescue
|
60
|
+
value = nil
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
value
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (c) 2010 Christian Kruse, <cjk@wwwtech.de>
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a
|
4
|
+
copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
The above copyright notice and this permission notice shall be included
|
11
|
+
in all copies or substantial portions of the Software.
|
12
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
13
|
+
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
14
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
15
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
16
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
17
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
18
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
19
|
+
|