ohai 18.0.26 → 18.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +28 -28
- data/LICENSE +201 -201
- data/bin/ohai +25 -25
- data/lib/ohai/application.rb +189 -189
- data/lib/ohai/common/dmi.rb +167 -167
- data/lib/ohai/config.rb +51 -51
- data/lib/ohai/dsl/plugin/versionvii.rb +203 -203
- data/lib/ohai/dsl/plugin.rb +232 -232
- data/lib/ohai/dsl.rb +22 -22
- data/lib/ohai/exception.rb +36 -36
- data/lib/ohai/hints.rb +68 -68
- data/lib/ohai/loader.rb +178 -178
- data/lib/ohai/log.rb +34 -34
- data/lib/ohai/mash.rb +22 -22
- data/lib/ohai/mixin/alibaba_metadata.rb +86 -86
- data/lib/ohai/mixin/azure_metadata.rb +111 -111
- data/lib/ohai/mixin/chef_utils_wiring.rb +52 -52
- data/lib/ohai/mixin/command.rb +4 -4
- data/lib/ohai/mixin/constant_helper.rb +55 -55
- data/lib/ohai/mixin/dmi_decode.rb +54 -54
- data/lib/ohai/mixin/do_metadata.rb +48 -48
- data/lib/ohai/mixin/ec2_metadata.rb +256 -256
- data/lib/ohai/mixin/gce_metadata.rb +83 -83
- data/lib/ohai/mixin/http_helper.rb +64 -64
- data/lib/ohai/mixin/network_helper.rb +65 -65
- data/lib/ohai/mixin/oci_metadata.rb +69 -0
- data/lib/ohai/mixin/os.rb +128 -128
- data/lib/ohai/mixin/scaleway_metadata.rb +51 -51
- data/lib/ohai/mixin/seconds_to_human.rb +52 -52
- data/lib/ohai/mixin/shell_out.rb +51 -51
- data/lib/ohai/mixin/softlayer_metadata.rb +74 -74
- data/lib/ohai/mixin/string.rb +31 -31
- data/lib/ohai/mixin/train_helpers.rb +36 -36
- data/lib/ohai/mixin/which.rb +39 -39
- data/lib/ohai/plugin_config.rb +47 -47
- data/lib/ohai/plugins/aix/kernel.rb +50 -50
- data/lib/ohai/plugins/aix/memory.rb +37 -37
- data/lib/ohai/plugins/aix/network.rb +142 -142
- data/lib/ohai/plugins/aix/platform.rb +30 -30
- data/lib/ohai/plugins/aix/uptime.rb +54 -54
- data/lib/ohai/plugins/aix/virtualization.rb +154 -154
- data/lib/ohai/plugins/alibaba.rb +72 -72
- data/lib/ohai/plugins/azure.rb +154 -154
- data/lib/ohai/plugins/bsd/virtualization.rb +121 -121
- data/lib/ohai/plugins/c.rb +178 -178
- data/lib/ohai/plugins/chef.rb +50 -50
- data/lib/ohai/plugins/cloud.rb +379 -357
- data/lib/ohai/plugins/command.rb +26 -26
- data/lib/ohai/plugins/cpu.rb +635 -635
- data/lib/ohai/plugins/darwin/hardware.rb +99 -99
- data/lib/ohai/plugins/darwin/memory.rb +62 -62
- data/lib/ohai/plugins/darwin/network.rb +207 -207
- data/lib/ohai/plugins/darwin/platform.rb +38 -38
- data/lib/ohai/plugins/darwin/virtualization.rb +90 -93
- data/lib/ohai/plugins/digital_ocean.rb +67 -67
- data/lib/ohai/plugins/dmi.rb +134 -134
- data/lib/ohai/plugins/docker.rb +58 -58
- data/lib/ohai/plugins/dragonflybsd/memory.rb +60 -60
- data/lib/ohai/plugins/dragonflybsd/network.rb +128 -128
- data/lib/ohai/plugins/dragonflybsd/platform.rb +28 -28
- data/lib/ohai/plugins/ec2.rb +148 -148
- data/lib/ohai/plugins/elixir.rb +36 -36
- data/lib/ohai/plugins/erlang.rb +60 -60
- data/lib/ohai/plugins/eucalyptus.rb +86 -86
- data/lib/ohai/plugins/filesystem.rb +751 -751
- data/lib/ohai/plugins/fips.rb +36 -36
- data/lib/ohai/plugins/freebsd/memory.rb +60 -60
- data/lib/ohai/plugins/freebsd/network.rb +128 -128
- data/lib/ohai/plugins/freebsd/platform.rb +28 -28
- data/lib/ohai/plugins/gce.rb +89 -89
- data/lib/ohai/plugins/go.rb +34 -34
- data/lib/ohai/plugins/groovy.rb +38 -38
- data/lib/ohai/plugins/grub2.rb +40 -40
- data/lib/ohai/plugins/habitat.rb +73 -73
- data/lib/ohai/plugins/haskell.rb +96 -96
- data/lib/ohai/plugins/hostname.rb +133 -133
- data/lib/ohai/plugins/init_package.rb +26 -26
- data/lib/ohai/plugins/java.rb +78 -78
- data/lib/ohai/plugins/kernel.rb +292 -292
- data/lib/ohai/plugins/keys.rb +27 -27
- data/lib/ohai/plugins/languages.rb +26 -26
- data/lib/ohai/plugins/libvirt.rb +114 -114
- data/lib/ohai/plugins/linode.rb +73 -73
- data/lib/ohai/plugins/linux/block_device.rb +48 -48
- data/lib/ohai/plugins/linux/hostnamectl.rb +34 -34
- data/lib/ohai/plugins/linux/interrupts.rb +84 -84
- data/lib/ohai/plugins/linux/ipc.rb +52 -52
- data/lib/ohai/plugins/linux/livepatch.rb +38 -38
- data/lib/ohai/plugins/linux/lsb.rb +46 -46
- data/lib/ohai/plugins/linux/lspci.rb +76 -76
- data/lib/ohai/plugins/linux/machineid.rb +36 -36
- data/lib/ohai/plugins/linux/mdadm.rb +120 -120
- data/lib/ohai/plugins/linux/memory.rb +106 -106
- data/lib/ohai/plugins/linux/network.rb +879 -879
- data/lib/ohai/plugins/linux/os_release.rb +38 -38
- data/lib/ohai/plugins/linux/platform.rb +314 -314
- data/lib/ohai/plugins/linux/selinux.rb +69 -69
- data/lib/ohai/plugins/linux/sessions.rb +54 -54
- data/lib/ohai/plugins/linux/sysctl.rb +39 -39
- data/lib/ohai/plugins/linux/systemd_paths.rb +36 -36
- data/lib/ohai/plugins/linux/tc.rb +61 -61
- data/lib/ohai/plugins/linux/virtualization.rb +300 -300
- data/lib/ohai/plugins/lua.rb +39 -39
- data/lib/ohai/plugins/mono.rb +50 -50
- data/lib/ohai/plugins/netbsd/memory.rb +99 -99
- data/lib/ohai/plugins/netbsd/network.rb +122 -122
- data/lib/ohai/plugins/netbsd/platform.rb +28 -28
- data/lib/ohai/plugins/network.rb +186 -186
- data/lib/ohai/plugins/nodejs.rb +40 -40
- data/lib/ohai/plugins/oci.rb +94 -0
- data/lib/ohai/plugins/ohai.rb +29 -29
- data/lib/ohai/plugins/ohai_time.rb +26 -26
- data/lib/ohai/plugins/openbsd/memory.rb +99 -99
- data/lib/ohai/plugins/openbsd/network.rb +122 -122
- data/lib/ohai/plugins/openbsd/platform.rb +28 -28
- data/lib/ohai/plugins/openstack.rb +84 -84
- data/lib/ohai/plugins/os.rb +55 -55
- data/lib/ohai/plugins/packages.rb +234 -234
- data/lib/ohai/plugins/passwd.rb +104 -104
- data/lib/ohai/plugins/perl.rb +45 -45
- data/lib/ohai/plugins/php.rb +52 -52
- data/lib/ohai/plugins/platform.rb +29 -29
- data/lib/ohai/plugins/powershell.rb +82 -82
- data/lib/ohai/plugins/ps.rb +35 -35
- data/lib/ohai/plugins/python.rb +43 -43
- data/lib/ohai/plugins/rackspace.rb +177 -177
- data/lib/ohai/plugins/root_group.rb +41 -41
- data/lib/ohai/plugins/rpm.rb +121 -121
- data/lib/ohai/plugins/ruby.rb +66 -66
- data/lib/ohai/plugins/rust.rb +34 -34
- data/lib/ohai/plugins/scala.rb +38 -38
- data/lib/ohai/plugins/scaleway.rb +58 -58
- data/lib/ohai/plugins/scsi.rb +52 -52
- data/lib/ohai/plugins/shard.rb +142 -142
- data/lib/ohai/plugins/shells.rb +32 -32
- data/lib/ohai/plugins/softlayer.rb +48 -48
- data/lib/ohai/plugins/solaris2/dmi.rb +191 -191
- data/lib/ohai/plugins/solaris2/memory.rb +32 -32
- data/lib/ohai/plugins/solaris2/network.rb +192 -192
- data/lib/ohai/plugins/solaris2/platform.rb +58 -58
- data/lib/ohai/plugins/solaris2/virtualization.rb +90 -90
- data/lib/ohai/plugins/ssh_host_key.rb +84 -84
- data/lib/ohai/plugins/sysconf.rb +46 -46
- data/lib/ohai/plugins/timezone.rb +45 -25
- data/lib/ohai/plugins/train.rb +35 -35
- data/lib/ohai/plugins/uptime.rb +95 -95
- data/lib/ohai/plugins/virtualbox.rb +197 -197
- data/lib/ohai/plugins/vmware.rb +109 -94
- data/lib/ohai/plugins/windows/dmi.rb +95 -95
- data/lib/ohai/plugins/windows/drivers.rb +52 -52
- data/lib/ohai/plugins/windows/memory.rb +39 -39
- data/lib/ohai/plugins/windows/network.rb +222 -222
- data/lib/ohai/plugins/windows/platform.rb +34 -34
- data/lib/ohai/plugins/windows/system_enclosure.rb +29 -29
- data/lib/ohai/plugins/windows/virtualization.rb +45 -45
- data/lib/ohai/plugins/zpools.rb +94 -94
- data/lib/ohai/provides_map.rb +208 -208
- data/lib/ohai/runner.rb +128 -128
- data/lib/ohai/system.rb +258 -258
- data/lib/ohai/train_transport.rb +29 -29
- data/lib/ohai/util/file_helper.rb +6 -6
- data/lib/ohai/util/ip_helper.rb +56 -56
- data/lib/ohai/util/win32.rb +47 -47
- data/lib/ohai/version.rb +23 -23
- data/lib/ohai.rb +23 -23
- data/ohai.gemspec +35 -35
- metadata +5 -3
@@ -1,90 +1,90 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
#
|
3
|
-
# Author:: Sean Walbran (<seanwalbran@gmail.com>)
|
4
|
-
# Author:: Kurt Yoder (<ktyopscode@yoderhome.com>)
|
5
|
-
# Copyright:: Copyright (c) Chef Software Inc.
|
6
|
-
# Copyright:: Copyright (c) 2010 Kurt Yoder
|
7
|
-
# License:: Apache License, Version 2.0
|
8
|
-
#
|
9
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
10
|
-
# you may not use this file except in compliance with the License.
|
11
|
-
# You may obtain a copy of the License at
|
12
|
-
#
|
13
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
14
|
-
#
|
15
|
-
# Unless required by applicable law or agreed to in writing, software
|
16
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
17
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
18
|
-
# See the License for the specific language governing permissions and
|
19
|
-
# limitations under the License.
|
20
|
-
#
|
21
|
-
|
22
|
-
Ohai.plugin(:Virtualization) do
|
23
|
-
require_relative "../../mixin/dmi_decode"
|
24
|
-
include Ohai::Mixin::DmiDecode
|
25
|
-
provides "virtualization"
|
26
|
-
depends "dmi"
|
27
|
-
|
28
|
-
def collect_solaris_guestid
|
29
|
-
shell_out("/usr/sbin/zoneadm list -p").stdout.split(":").first
|
30
|
-
end
|
31
|
-
|
32
|
-
collect_data(:solaris2) do
|
33
|
-
virtualization Mash.new
|
34
|
-
virtualization[:systems] = Mash.new
|
35
|
-
|
36
|
-
# Detect paravirt KVM/QEMU from cpuinfo, report as KVM
|
37
|
-
psrinfo_path = Ohai.abs_path( "/usr/sbin/psrinfo" )
|
38
|
-
if file_exist?(psrinfo_path)
|
39
|
-
so = shell_out("#{psrinfo_path} -pv")
|
40
|
-
if /QEMU Virtual CPU|Common KVM processor|Common 32-bit KVM processor/.match?(so.stdout)
|
41
|
-
virtualization[:system] = "kvm"
|
42
|
-
virtualization[:role] = "guest"
|
43
|
-
virtualization[:systems][:kvm] = "guest"
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
# parse dmi to discover various virtualization guests
|
48
|
-
guest = guest_from_dmi_data(get_attribute(:dmi, :system, :manufacturer), get_attribute(:dmi, :system, :product), get_attribute(:dmi, :system, :version))
|
49
|
-
if guest
|
50
|
-
logger.trace("Plugin Virtualization: DMI data indicates #{guest} guest")
|
51
|
-
virtualization[:system] = guest
|
52
|
-
virtualization[:role] = "guest"
|
53
|
-
virtualization[:systems][guest.to_sym] = "guest"
|
54
|
-
end
|
55
|
-
|
56
|
-
if File.executable?("/usr/sbin/zoneadm")
|
57
|
-
zones = Mash.new
|
58
|
-
shell_out("zoneadm list -pc").stdout.lines do |line|
|
59
|
-
info = line.chomp.split(":")
|
60
|
-
zones[info[1]] = {
|
61
|
-
"id" => info[0],
|
62
|
-
"state" => info[2],
|
63
|
-
"root" => info[3],
|
64
|
-
"uuid" => info[4],
|
65
|
-
"brand" => info[5],
|
66
|
-
"ip" => info[6],
|
67
|
-
}
|
68
|
-
end
|
69
|
-
|
70
|
-
if zones.length == 1
|
71
|
-
first_zone = zones.keys[0]
|
72
|
-
virtualization[:system] = "zone"
|
73
|
-
if first_zone == "global"
|
74
|
-
virtualization[:role] = "host"
|
75
|
-
virtualization[:systems][:zone] = "host"
|
76
|
-
else
|
77
|
-
virtualization[:role] = "guest"
|
78
|
-
virtualization[:systems][:zone] = "guest"
|
79
|
-
virtualization[:guest_uuid] = zones[first_zone]["uuid"]
|
80
|
-
virtualization[:guest_id] = collect_solaris_guestid
|
81
|
-
end
|
82
|
-
elsif zones.length > 1
|
83
|
-
virtualization[:system] = "zone"
|
84
|
-
virtualization[:role] = "host"
|
85
|
-
virtualization[:systems][:zone] = "host"
|
86
|
-
virtualization[:guests] = zones
|
87
|
-
end
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
#
|
3
|
+
# Author:: Sean Walbran (<seanwalbran@gmail.com>)
|
4
|
+
# Author:: Kurt Yoder (<ktyopscode@yoderhome.com>)
|
5
|
+
# Copyright:: Copyright (c) Chef Software Inc.
|
6
|
+
# Copyright:: Copyright (c) 2010 Kurt Yoder
|
7
|
+
# License:: Apache License, Version 2.0
|
8
|
+
#
|
9
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
10
|
+
# you may not use this file except in compliance with the License.
|
11
|
+
# You may obtain a copy of the License at
|
12
|
+
#
|
13
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
14
|
+
#
|
15
|
+
# Unless required by applicable law or agreed to in writing, software
|
16
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
17
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
18
|
+
# See the License for the specific language governing permissions and
|
19
|
+
# limitations under the License.
|
20
|
+
#
|
21
|
+
|
22
|
+
Ohai.plugin(:Virtualization) do
|
23
|
+
require_relative "../../mixin/dmi_decode"
|
24
|
+
include Ohai::Mixin::DmiDecode
|
25
|
+
provides "virtualization"
|
26
|
+
depends "dmi"
|
27
|
+
|
28
|
+
def collect_solaris_guestid
|
29
|
+
shell_out("/usr/sbin/zoneadm list -p").stdout.split(":").first
|
30
|
+
end
|
31
|
+
|
32
|
+
collect_data(:solaris2) do
|
33
|
+
virtualization Mash.new
|
34
|
+
virtualization[:systems] = Mash.new
|
35
|
+
|
36
|
+
# Detect paravirt KVM/QEMU from cpuinfo, report as KVM
|
37
|
+
psrinfo_path = Ohai.abs_path( "/usr/sbin/psrinfo" )
|
38
|
+
if file_exist?(psrinfo_path)
|
39
|
+
so = shell_out("#{psrinfo_path} -pv")
|
40
|
+
if /QEMU Virtual CPU|Common KVM processor|Common 32-bit KVM processor/.match?(so.stdout)
|
41
|
+
virtualization[:system] = "kvm"
|
42
|
+
virtualization[:role] = "guest"
|
43
|
+
virtualization[:systems][:kvm] = "guest"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
# parse dmi to discover various virtualization guests
|
48
|
+
guest = guest_from_dmi_data(get_attribute(:dmi, :system, :manufacturer), get_attribute(:dmi, :system, :product), get_attribute(:dmi, :system, :version))
|
49
|
+
if guest
|
50
|
+
logger.trace("Plugin Virtualization: DMI data indicates #{guest} guest")
|
51
|
+
virtualization[:system] = guest
|
52
|
+
virtualization[:role] = "guest"
|
53
|
+
virtualization[:systems][guest.to_sym] = "guest"
|
54
|
+
end
|
55
|
+
|
56
|
+
if File.executable?("/usr/sbin/zoneadm")
|
57
|
+
zones = Mash.new
|
58
|
+
shell_out("zoneadm list -pc").stdout.lines do |line|
|
59
|
+
info = line.chomp.split(":")
|
60
|
+
zones[info[1]] = {
|
61
|
+
"id" => info[0],
|
62
|
+
"state" => info[2],
|
63
|
+
"root" => info[3],
|
64
|
+
"uuid" => info[4],
|
65
|
+
"brand" => info[5],
|
66
|
+
"ip" => info[6],
|
67
|
+
}
|
68
|
+
end
|
69
|
+
|
70
|
+
if zones.length == 1
|
71
|
+
first_zone = zones.keys[0]
|
72
|
+
virtualization[:system] = "zone"
|
73
|
+
if first_zone == "global"
|
74
|
+
virtualization[:role] = "host"
|
75
|
+
virtualization[:systems][:zone] = "host"
|
76
|
+
else
|
77
|
+
virtualization[:role] = "guest"
|
78
|
+
virtualization[:systems][:zone] = "guest"
|
79
|
+
virtualization[:guest_uuid] = zones[first_zone]["uuid"]
|
80
|
+
virtualization[:guest_id] = collect_solaris_guestid
|
81
|
+
end
|
82
|
+
elsif zones.length > 1
|
83
|
+
virtualization[:system] = "zone"
|
84
|
+
virtualization[:role] = "host"
|
85
|
+
virtualization[:systems][:zone] = "host"
|
86
|
+
virtualization[:guests] = zones
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
@@ -1,84 +1,84 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
#
|
3
|
-
# Author:: Bryan McLellan <btm@chef.io>
|
4
|
-
# Copyright:: Copyright (c) Chef Software Inc.
|
5
|
-
# License:: Apache License, Version 2.0
|
6
|
-
#
|
7
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
-
# you may not use this file except in compliance with the License.
|
9
|
-
# You may obtain a copy of the License at
|
10
|
-
#
|
11
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
-
#
|
13
|
-
# Unless required by applicable law or agreed to in writing, software
|
14
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
-
# See the License for the specific language governing permissions and
|
17
|
-
# limitations under the License.
|
18
|
-
#
|
19
|
-
|
20
|
-
Ohai.plugin(:SSHHostKey) do
|
21
|
-
provides "keys/ssh"
|
22
|
-
depends "keys"
|
23
|
-
|
24
|
-
def extract_keytype?(content)
|
25
|
-
case content[0]
|
26
|
-
when "ssh-dss"
|
27
|
-
[ "dsa", nil ]
|
28
|
-
when "ssh-rsa"
|
29
|
-
[ "rsa", nil ]
|
30
|
-
when /^ecdsa/
|
31
|
-
[ "ecdsa", content[0] ]
|
32
|
-
when "ssh-ed25519"
|
33
|
-
[ "ed25519", nil ]
|
34
|
-
else
|
35
|
-
[ nil, nil ]
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
collect_data do
|
40
|
-
keys[:ssh] = Mash.new
|
41
|
-
|
42
|
-
sshd_config = if file_exist?("/etc/ssh/sshd_config")
|
43
|
-
"/etc/ssh/sshd_config"
|
44
|
-
elsif file_exist?("/etc/sshd_config")
|
45
|
-
# Darwin
|
46
|
-
"/etc/sshd_config"
|
47
|
-
else
|
48
|
-
logger.trace("Plugin SSHHostKey: Failed to find sshd configuration file")
|
49
|
-
nil
|
50
|
-
end
|
51
|
-
|
52
|
-
if sshd_config
|
53
|
-
file_open(sshd_config) do |conf|
|
54
|
-
conf.each_line do |line|
|
55
|
-
if /^hostkey\s/i.match?(line)
|
56
|
-
pub_file = "#{line.split[1]}.pub"
|
57
|
-
content = file_read(pub_file).split
|
58
|
-
key_type, key_subtype = extract_keytype?(content)
|
59
|
-
keys[:ssh]["host_#{key_type}_public"] = content[1] unless key_type.nil?
|
60
|
-
keys[:ssh]["host_#{key_type}_type"] = key_subtype unless key_subtype.nil?
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
if keys[:ssh][:host_dsa_public].nil? && file_exist?("/etc/ssh/ssh_host_dsa_key.pub")
|
67
|
-
keys[:ssh][:host_dsa_public] = file_read("/etc/ssh/ssh_host_dsa_key.pub").split[1]
|
68
|
-
end
|
69
|
-
|
70
|
-
if keys[:ssh][:host_rsa_public].nil? && file_exist?("/etc/ssh/ssh_host_rsa_key.pub")
|
71
|
-
keys[:ssh][:host_rsa_public] = file_read("/etc/ssh/ssh_host_rsa_key.pub").split[1]
|
72
|
-
end
|
73
|
-
|
74
|
-
if keys[:ssh][:host_ecdsa_public].nil? && file_exist?("/etc/ssh/ssh_host_ecdsa_key.pub")
|
75
|
-
content = file_read("/etc/ssh/ssh_host_ecdsa_key.pub")
|
76
|
-
keys[:ssh][:host_ecdsa_public] = content.split[1]
|
77
|
-
keys[:ssh][:host_ecdsa_type] = content.split[0]
|
78
|
-
end
|
79
|
-
|
80
|
-
if keys[:ssh][:host_ed25519_public].nil? && file_exist?("/etc/ssh/ssh_host_ed25519_key.pub")
|
81
|
-
keys[:ssh][:host_ed25519_public] = file_read("/etc/ssh/ssh_host_ed25519_key.pub").split[1]
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
#
|
3
|
+
# Author:: Bryan McLellan <btm@chef.io>
|
4
|
+
# Copyright:: Copyright (c) Chef Software Inc.
|
5
|
+
# License:: Apache License, Version 2.0
|
6
|
+
#
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
# you may not use this file except in compliance with the License.
|
9
|
+
# You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
+
# See the License for the specific language governing permissions and
|
17
|
+
# limitations under the License.
|
18
|
+
#
|
19
|
+
|
20
|
+
Ohai.plugin(:SSHHostKey) do
|
21
|
+
provides "keys/ssh"
|
22
|
+
depends "keys"
|
23
|
+
|
24
|
+
def extract_keytype?(content)
|
25
|
+
case content[0]
|
26
|
+
when "ssh-dss"
|
27
|
+
[ "dsa", nil ]
|
28
|
+
when "ssh-rsa"
|
29
|
+
[ "rsa", nil ]
|
30
|
+
when /^ecdsa/
|
31
|
+
[ "ecdsa", content[0] ]
|
32
|
+
when "ssh-ed25519"
|
33
|
+
[ "ed25519", nil ]
|
34
|
+
else
|
35
|
+
[ nil, nil ]
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
collect_data do
|
40
|
+
keys[:ssh] = Mash.new
|
41
|
+
|
42
|
+
sshd_config = if file_exist?("/etc/ssh/sshd_config")
|
43
|
+
"/etc/ssh/sshd_config"
|
44
|
+
elsif file_exist?("/etc/sshd_config")
|
45
|
+
# Darwin
|
46
|
+
"/etc/sshd_config"
|
47
|
+
else
|
48
|
+
logger.trace("Plugin SSHHostKey: Failed to find sshd configuration file")
|
49
|
+
nil
|
50
|
+
end
|
51
|
+
|
52
|
+
if sshd_config
|
53
|
+
file_open(sshd_config) do |conf|
|
54
|
+
conf.each_line do |line|
|
55
|
+
if /^hostkey\s/i.match?(line)
|
56
|
+
pub_file = "#{line.split[1]}.pub"
|
57
|
+
content = file_read(pub_file).split
|
58
|
+
key_type, key_subtype = extract_keytype?(content)
|
59
|
+
keys[:ssh]["host_#{key_type}_public"] = content[1] unless key_type.nil?
|
60
|
+
keys[:ssh]["host_#{key_type}_type"] = key_subtype unless key_subtype.nil?
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
if keys[:ssh][:host_dsa_public].nil? && file_exist?("/etc/ssh/ssh_host_dsa_key.pub")
|
67
|
+
keys[:ssh][:host_dsa_public] = file_read("/etc/ssh/ssh_host_dsa_key.pub").split[1]
|
68
|
+
end
|
69
|
+
|
70
|
+
if keys[:ssh][:host_rsa_public].nil? && file_exist?("/etc/ssh/ssh_host_rsa_key.pub")
|
71
|
+
keys[:ssh][:host_rsa_public] = file_read("/etc/ssh/ssh_host_rsa_key.pub").split[1]
|
72
|
+
end
|
73
|
+
|
74
|
+
if keys[:ssh][:host_ecdsa_public].nil? && file_exist?("/etc/ssh/ssh_host_ecdsa_key.pub")
|
75
|
+
content = file_read("/etc/ssh/ssh_host_ecdsa_key.pub")
|
76
|
+
keys[:ssh][:host_ecdsa_public] = content.split[1]
|
77
|
+
keys[:ssh][:host_ecdsa_type] = content.split[0]
|
78
|
+
end
|
79
|
+
|
80
|
+
if keys[:ssh][:host_ed25519_public].nil? && file_exist?("/etc/ssh/ssh_host_ed25519_key.pub")
|
81
|
+
keys[:ssh][:host_ed25519_public] = file_read("/etc/ssh/ssh_host_ed25519_key.pub").split[1]
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
data/lib/ohai/plugins/sysconf.rb
CHANGED
@@ -1,46 +1,46 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
#
|
3
|
-
# Author:: Davide Cavalca <dcavalca@fb.com>
|
4
|
-
# Copyright:: Copyright (c) 2016 Facebook
|
5
|
-
# License:: Apache License, Version 2.0
|
6
|
-
#
|
7
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
-
# you may not use this file except in compliance with the License.
|
9
|
-
# You may obtain a copy of the License at
|
10
|
-
#
|
11
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
-
#
|
13
|
-
# Unless required by applicable law or agreed to in writing, software
|
14
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
-
# See the License for the specific language governing permissions and
|
17
|
-
# limitations under the License.
|
18
|
-
#
|
19
|
-
|
20
|
-
Ohai.plugin(:Sysconf) do
|
21
|
-
provides "sysconf"
|
22
|
-
|
23
|
-
collect_data(:aix, :linux, :solaris2) do
|
24
|
-
getconf_path = which("getconf")
|
25
|
-
if getconf_path
|
26
|
-
getconf = shell_out("#{getconf_path} -a")
|
27
|
-
|
28
|
-
if getconf.exitstatus == 0
|
29
|
-
sysconf Mash.new unless sysconf
|
30
|
-
|
31
|
-
getconf.stdout.split("\n").each do |line|
|
32
|
-
key, val = /^(\S+)\s*(.*)?$/.match(line).captures
|
33
|
-
if val && !val.empty?
|
34
|
-
begin
|
35
|
-
sysconf[key] = Integer(val)
|
36
|
-
rescue
|
37
|
-
sysconf[key] = val
|
38
|
-
end
|
39
|
-
else
|
40
|
-
sysconf[key] = nil
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
#
|
3
|
+
# Author:: Davide Cavalca <dcavalca@fb.com>
|
4
|
+
# Copyright:: Copyright (c) 2016 Facebook
|
5
|
+
# License:: Apache License, Version 2.0
|
6
|
+
#
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
# you may not use this file except in compliance with the License.
|
9
|
+
# You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
+
# See the License for the specific language governing permissions and
|
17
|
+
# limitations under the License.
|
18
|
+
#
|
19
|
+
|
20
|
+
Ohai.plugin(:Sysconf) do
|
21
|
+
provides "sysconf"
|
22
|
+
|
23
|
+
collect_data(:aix, :linux, :solaris2) do
|
24
|
+
getconf_path = which("getconf")
|
25
|
+
if getconf_path
|
26
|
+
getconf = shell_out("#{getconf_path} -a")
|
27
|
+
|
28
|
+
if getconf.exitstatus == 0
|
29
|
+
sysconf Mash.new unless sysconf
|
30
|
+
|
31
|
+
getconf.stdout.split("\n").each do |line|
|
32
|
+
key, val = /^(\S+)\s*(.*)?$/.match(line).captures
|
33
|
+
if val && !val.empty?
|
34
|
+
begin
|
35
|
+
sysconf[key] = Integer(val)
|
36
|
+
rescue
|
37
|
+
sysconf[key] = val
|
38
|
+
end
|
39
|
+
else
|
40
|
+
sysconf[key] = nil
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -1,25 +1,45 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
#
|
3
|
-
# Author:: John Bellone (<jbellone@bloomberg.net>)
|
4
|
-
# License:: Apache License, Version 2.0
|
5
|
-
#
|
6
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
-
# you may not use this file except in compliance with the License.
|
8
|
-
# You may obtain a copy of the License at
|
9
|
-
#
|
10
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
12
|
-
# Unless required by applicable law or agreed to in writing, software
|
13
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
-
# See the License for the specific language governing permissions and
|
16
|
-
# limitations under the License.
|
17
|
-
|
18
|
-
Ohai.plugin(:Timezone) do
|
19
|
-
provides "time/timezone"
|
20
|
-
|
21
|
-
collect_data(:default) do
|
22
|
-
time Mash.new unless time
|
23
|
-
time[:timezone] = Time.now.getlocal.zone
|
24
|
-
|
25
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
#
|
3
|
+
# Author:: John Bellone (<jbellone@bloomberg.net>)
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
|
18
|
+
Ohai.plugin(:Timezone) do
|
19
|
+
provides "time/timezone"
|
20
|
+
|
21
|
+
collect_data(:default) do
|
22
|
+
time Mash.new unless time
|
23
|
+
time[:timezone] = Time.now.getlocal.zone
|
24
|
+
|
25
|
+
# Windows in German display language outputs LATIN1 bytes for .zone, but marks them as
|
26
|
+
# IBM437, which somehow fails any attempt at conversion to other encodings when
|
27
|
+
# ä is present, as in the timezone name "Mitteleuropäische Zeit" (Central Europe Time)
|
28
|
+
#
|
29
|
+
# Windows-1252 is the legacy encoding for Windows for German that actually
|
30
|
+
# translates (ISO-8859-1 works as well), but going with the more correct
|
31
|
+
# encoding name for Windows' implementation of Latin-1
|
32
|
+
#
|
33
|
+
# References
|
34
|
+
# * [Code Page 437/IBM437](https://en.wikipedia.org/wiki/Code_page_437)
|
35
|
+
# * [ISO/IEC 8859-1](https://en.wikipedia.org/wiki/ISO/IEC_8859-1)
|
36
|
+
# * [Windows-1252](https://en.wikipedia.org/wiki/Windows-1252)
|
37
|
+
if time[:timezone].encoding == Encoding::IBM437
|
38
|
+
# Assume encoding is WINDOWS_1252
|
39
|
+
time[:timezone] = time[:timezone].force_encoding(Encoding::WINDOWS_1252)
|
40
|
+
# Re-encode in UTF_8. Note: If other encodings have problems converting
|
41
|
+
# it might be worth re-encode everything in UTF_8.
|
42
|
+
time[:timezone] = time[:timezone].encode(Encoding::UTF_8)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
data/lib/ohai/plugins/train.rb
CHANGED
@@ -1,35 +1,35 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
#
|
3
|
-
# Copyright:: Copyright (c) Chef Software Inc.
|
4
|
-
# License:: Apache License, Version 2.0
|
5
|
-
#
|
6
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
-
# you may not use this file except in compliance with the License.
|
8
|
-
# You may obtain a copy of the License at
|
9
|
-
#
|
10
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
12
|
-
# Unless required by applicable law or agreed to in writing, software
|
13
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
-
# See the License for the specific language governing permissions and
|
16
|
-
# limitations under the License.
|
17
|
-
#
|
18
|
-
|
19
|
-
Ohai.plugin(:Train) do
|
20
|
-
provides "train"
|
21
|
-
|
22
|
-
collect_data do
|
23
|
-
if transport_connection
|
24
|
-
train Mash.new
|
25
|
-
train["family_hierarchy"] = transport_connection.platform.family_hierarchy
|
26
|
-
train["family"] = transport_connection.platform.family
|
27
|
-
train["platform"] = transport_connection.platform.platform
|
28
|
-
train["backend"] = transport_connection.backend_type
|
29
|
-
if transport_connection.respond_to?(:uri)
|
30
|
-
train["scheme"] = URI.parse(transport_connection.uri).scheme
|
31
|
-
train["uri"] = transport_connection.uri
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
#
|
3
|
+
# Copyright:: Copyright (c) Chef Software Inc.
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
|
19
|
+
Ohai.plugin(:Train) do
|
20
|
+
provides "train"
|
21
|
+
|
22
|
+
collect_data do
|
23
|
+
if transport_connection
|
24
|
+
train Mash.new
|
25
|
+
train["family_hierarchy"] = transport_connection.platform.family_hierarchy
|
26
|
+
train["family"] = transport_connection.platform.family
|
27
|
+
train["platform"] = transport_connection.platform.platform
|
28
|
+
train["backend"] = transport_connection.backend_type
|
29
|
+
if transport_connection.respond_to?(:uri)
|
30
|
+
train["scheme"] = URI.parse(transport_connection.uri).scheme
|
31
|
+
train["uri"] = transport_connection.uri
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|