ohai 13.12.6 → 14.0.28

Sign up to get free protection for your applications and to get access to all the features.
Files changed (160) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +3 -12
  3. data/README.md +7 -12
  4. data/Rakefile +16 -23
  5. data/docs/man/man1/ohai.1 +97 -0
  6. data/lib/ohai/application.rb +9 -4
  7. data/lib/ohai/common/dmi.rb +4 -16
  8. data/lib/ohai/config.rb +5 -1
  9. data/lib/ohai/dsl.rb +0 -1
  10. data/lib/ohai/dsl/plugin.rb +12 -16
  11. data/lib/ohai/dsl/plugin/versionvii.rb +17 -5
  12. data/lib/ohai/hints.rb +2 -2
  13. data/lib/ohai/loader.rb +21 -70
  14. data/lib/ohai/log.rb +1 -1
  15. data/lib/ohai/mixin/azure_metadata.rb +4 -4
  16. data/lib/ohai/mixin/command.rb +3 -3
  17. data/lib/ohai/mixin/dmi_decode.rb +0 -2
  18. data/lib/ohai/mixin/do_metadata.rb +1 -1
  19. data/lib/ohai/mixin/ec2_metadata.rb +8 -8
  20. data/lib/ohai/mixin/gce_metadata.rb +1 -5
  21. data/lib/ohai/mixin/http_helper.rb +3 -3
  22. data/lib/ohai/mixin/scaleway_metadata.rb +46 -0
  23. data/lib/ohai/mixin/softlayer_metadata.rb +3 -3
  24. data/lib/ohai/plugins/aix/filesystem.rb +1 -1
  25. data/lib/ohai/plugins/aix/memory.rb +1 -1
  26. data/lib/ohai/plugins/aix/network.rb +2 -2
  27. data/lib/ohai/plugins/aix/virtualization.rb +1 -1
  28. data/lib/ohai/plugins/azure.rb +5 -5
  29. data/lib/ohai/plugins/bsd/virtualization.rb +11 -11
  30. data/lib/ohai/plugins/c.rb +8 -8
  31. data/lib/ohai/plugins/chef.rb +2 -1
  32. data/lib/ohai/plugins/cloud.rb +0 -3
  33. data/lib/ohai/plugins/darwin/cpu.rb +2 -2
  34. data/lib/ohai/plugins/darwin/filesystem.rb +0 -2
  35. data/lib/ohai/plugins/darwin/hardware.rb +9 -3
  36. data/lib/ohai/plugins/darwin/network.rb +2 -2
  37. data/lib/ohai/plugins/darwin/system_profiler.rb +19 -19
  38. data/lib/ohai/plugins/darwin/virtualization.rb +10 -0
  39. data/lib/ohai/plugins/digital_ocean.rb +4 -4
  40. data/lib/ohai/plugins/dmi.rb +15 -14
  41. data/lib/ohai/plugins/docker.rb +57 -0
  42. data/lib/ohai/plugins/ec2.rb +11 -11
  43. data/lib/ohai/plugins/elixir.rb +1 -1
  44. data/lib/ohai/plugins/erlang.rb +2 -2
  45. data/lib/ohai/plugins/eucalyptus.rb +5 -5
  46. data/lib/ohai/plugins/gce.rb +2 -2
  47. data/lib/ohai/plugins/go.rb +1 -1
  48. data/lib/ohai/plugins/groovy.rb +1 -1
  49. data/lib/ohai/plugins/haskell.rb +4 -4
  50. data/lib/ohai/plugins/hostname.rb +6 -6
  51. data/lib/ohai/plugins/init_package.rb +1 -1
  52. data/lib/ohai/plugins/java.rb +1 -1
  53. data/lib/ohai/plugins/kernel.rb +109 -40
  54. data/lib/ohai/plugins/libvirt.rb +113 -0
  55. data/lib/ohai/plugins/linode.rb +4 -4
  56. data/lib/ohai/plugins/linux/block_device.rb +4 -4
  57. data/lib/ohai/plugins/linux/cpu.rb +3 -3
  58. data/lib/ohai/plugins/linux/filesystem.rb +4 -6
  59. data/lib/ohai/plugins/linux/lsb.rb +3 -3
  60. data/lib/ohai/plugins/linux/lspci.rb +2 -1
  61. data/lib/ohai/plugins/linux/machineid.rb +4 -4
  62. data/lib/ohai/plugins/linux/network.rb +16 -16
  63. data/lib/ohai/plugins/linux/platform.rb +4 -10
  64. data/lib/ohai/plugins/linux/sessions.rb +2 -1
  65. data/lib/ohai/plugins/linux/virtualization.rb +53 -31
  66. data/lib/ohai/plugins/lua.rb +1 -1
  67. data/lib/ohai/plugins/mono.rb +2 -2
  68. data/lib/ohai/plugins/network.rb +11 -11
  69. data/lib/ohai/plugins/nodejs.rb +1 -1
  70. data/lib/ohai/plugins/ohai.rb +0 -2
  71. data/lib/ohai/plugins/openstack.rb +7 -10
  72. data/lib/ohai/plugins/packages.rb +1 -1
  73. data/lib/ohai/plugins/passwd.rb +1 -0
  74. data/lib/ohai/plugins/perl.rb +1 -1
  75. data/lib/ohai/plugins/php.rb +1 -1
  76. data/lib/ohai/plugins/powershell.rb +1 -1
  77. data/lib/ohai/plugins/python.rb +1 -1
  78. data/lib/ohai/plugins/rackspace.rb +5 -5
  79. data/lib/ohai/plugins/root_group.rb +6 -9
  80. data/lib/ohai/plugins/ruby.rb +2 -2
  81. data/lib/ohai/plugins/rust.rb +1 -1
  82. data/lib/ohai/plugins/scala.rb +1 -1
  83. data/lib/ohai/plugins/scaleway.rb +56 -0
  84. data/lib/ohai/plugins/shard.rb +1 -0
  85. data/lib/ohai/plugins/softlayer.rb +2 -2
  86. data/lib/ohai/plugins/solaris2/cpu.rb +1 -1
  87. data/lib/ohai/plugins/solaris2/dmi.rb +13 -13
  88. data/lib/ohai/plugins/solaris2/network.rb +6 -6
  89. data/lib/ohai/plugins/solaris2/platform.rb +2 -2
  90. data/lib/ohai/plugins/ssh_host_key.rb +7 -7
  91. data/lib/ohai/plugins/uptime.rb +2 -7
  92. data/lib/ohai/plugins/virtualbox.rb +1 -1
  93. data/lib/ohai/plugins/vmware.rb +2 -2
  94. data/lib/ohai/plugins/windows/cpu.rb +2 -16
  95. data/lib/ohai/plugins/windows/network.rb +4 -2
  96. data/lib/ohai/plugins/zpools.rb +3 -3
  97. data/lib/ohai/provides_map.rb +1 -1
  98. data/lib/ohai/runner.rb +11 -14
  99. data/lib/ohai/system.rb +8 -71
  100. data/lib/ohai/util/file_helper.rb +2 -2
  101. data/lib/ohai/util/win32/group_helper.rb +0 -2
  102. data/lib/ohai/version.rb +1 -1
  103. data/ohai.gemspec +6 -5
  104. data/spec/functional/plugins/root_group_spec.rb +2 -2
  105. data/spec/functional/plugins/windows/uptime_spec.rb +0 -29
  106. data/spec/unit/dsl/plugin_spec.rb +14 -46
  107. data/spec/unit/loader_spec.rb +8 -70
  108. data/spec/unit/mixin/azure_metadata_spec.rb +9 -4
  109. data/spec/unit/mixin/command_spec.rb +11 -8
  110. data/spec/unit/mixin/ec2_metadata_spec.rb +5 -0
  111. data/spec/unit/mixin/softlayer_metadata_spec.rb +6 -1
  112. data/spec/unit/plugins/aix/filesystem_spec.rb +10 -10
  113. data/spec/unit/plugins/aix/network_spec.rb +1 -1
  114. data/spec/unit/plugins/aix/virtualization_spec.rb +3 -3
  115. data/spec/unit/plugins/cloud_spec.rb +0 -12
  116. data/spec/unit/plugins/darwin/cpu_spec.rb +2 -2
  117. data/spec/unit/plugins/darwin/filesystem_spec.rb +1 -6
  118. data/spec/unit/plugins/darwin/hardware_spec.rb +1 -1
  119. data/spec/unit/plugins/darwin/virtualization_spec.rb +8 -0
  120. data/spec/unit/plugins/dmi_spec.rb +17 -25
  121. data/spec/unit/plugins/docker_spec.rb +100 -0
  122. data/spec/unit/plugins/fail_spec.rb +3 -58
  123. data/spec/unit/plugins/haskell_spec.rb +1 -1
  124. data/spec/unit/plugins/init_package_spec.rb +1 -1
  125. data/spec/unit/plugins/kernel_spec.rb +0 -52
  126. data/spec/unit/plugins/linux/block_device_spec.rb +2 -2
  127. data/spec/unit/plugins/linux/filesystem_spec.rb +2 -7
  128. data/spec/unit/plugins/linux/lsb_spec.rb +5 -5
  129. data/spec/unit/plugins/linux/lspci_spec.rb +2 -2
  130. data/spec/unit/plugins/linux/machineid_spec.rb +5 -5
  131. data/spec/unit/plugins/linux/network_spec.rb +16 -16
  132. data/spec/unit/plugins/linux/platform_spec.rb +1 -17
  133. data/spec/unit/plugins/linux/virtualization_spec.rb +21 -1
  134. data/spec/unit/plugins/network_spec.rb +58 -58
  135. data/spec/unit/plugins/openstack_spec.rb +5 -24
  136. data/spec/unit/plugins/rackspace_spec.rb +6 -6
  137. data/spec/unit/plugins/root_group_spec.rb +1 -1
  138. data/spec/unit/plugins/ruby_spec.rb +1 -1
  139. data/spec/unit/plugins/rust_spec.rb +1 -1
  140. data/spec/unit/plugins/scala_spec.rb +1 -1
  141. data/spec/unit/plugins/scaleway_spec.rb +91 -0
  142. data/spec/unit/plugins/solaris2/cpu_spec.rb +3 -3
  143. data/spec/unit/plugins/solaris2/platform_spec.rb +2 -2
  144. data/spec/unit/plugins/ssh_host_keys_spec.rb +8 -8
  145. data/spec/unit/plugins/sysconf_spec.rb +1 -0
  146. data/spec/unit/plugins/windows/kernel_spec.rb +79 -0
  147. data/spec/unit/plugins/windows/uptime_spec.rb +8 -58
  148. data/spec/unit/provides_map_spec.rb +4 -4
  149. data/spec/unit/runner_spec.rb +15 -54
  150. data/spec/unit/system_spec.rb +35 -348
  151. data/spec/unit/util/file_helper_spec.rb +2 -0
  152. metadata +28 -28
  153. data/lib/ohai/dsl/plugin/versionvi.rb +0 -61
  154. data/lib/ohai/plugins/bsd/filesystem2.rb +0 -121
  155. data/lib/ohai/plugins/ip_scopes.rb +0 -67
  156. data/lib/ohai/plugins/virtualization.rb +0 -83
  157. data/spec/data/plugins/messages.rb +0 -8
  158. data/spec/data/plugins/v6message.rb +0 -2
  159. data/spec/unit/plugins/bsd/filesystem2_spec.rb +0 -126
  160. data/spec/unit/plugins/ip_scopes_spec.rb +0 -139
@@ -18,6 +18,7 @@
18
18
 
19
19
  Ohai.plugin(:Sessions) do
20
20
  provides "sessions/by_session", "sessions/by_user"
21
+ optional true
21
22
 
22
23
  collect_data(:linux) do
23
24
  loginctl_path = which("loginctl")
@@ -46,7 +47,7 @@ Ohai.plugin(:Sessions) do
46
47
  end
47
48
  end
48
49
  else
49
- Ohai::Log.debug("Plugin Sessions: Could not find loginctl. Skipping plugin.")
50
+ logger.trace("Plugin Sessions: Could not find loginctl. Skipping plugin.")
50
51
  end
51
52
  end
52
53
  end
@@ -29,12 +29,27 @@ Ohai.plugin(:Virtualization) do
29
29
  which("nova")
30
30
  end
31
31
 
32
+ def docker_exists?
33
+ which("docker")
34
+ end
35
+
32
36
  collect_data(:linux) do
33
37
  virtualization Mash.new unless virtualization
34
38
  virtualization[:systems] = Mash.new unless virtualization[:systems]
35
39
 
36
- ## Xen
37
- # /proc/xen is an empty dir for EL6 + Linode Guests + Paravirt EC2 instances
40
+ # Docker hosts
41
+ if docker_exists?
42
+ virtualization[:system] = "docker"
43
+ virtualization[:role] = "host"
44
+ virtualization[:systems][:docker] = "host"
45
+ end
46
+
47
+ # Xen Notes:
48
+ # - /proc/xen is an empty dir for EL6 + Linode Guests + Paravirt EC2 instances
49
+ # - cpuid of guests, if we could get it, would also be a clue
50
+ # - may be able to determine if under paravirt from /dev/xen/evtchn (See OHAI-253)
51
+ # - Additional edge cases likely should not change the above assumptions
52
+ # but rather be additive - btm
38
53
  if File.exist?("/proc/xen")
39
54
  virtualization[:system] = "xen"
40
55
  # Assume guest
@@ -44,29 +59,23 @@ Ohai.plugin(:Virtualization) do
44
59
  # This file should exist on most Xen systems, normally empty for guests
45
60
  if File.exist?("/proc/xen/capabilities")
46
61
  if File.read("/proc/xen/capabilities") =~ /control_d/i
47
- Ohai::Log.debug("Plugin Virtualization: /proc/xen/capabilities contains control_d. Detecting as Xen host")
62
+ logger.trace("Plugin Virtualization: /proc/xen/capabilities contains control_d. Detecting as Xen host")
48
63
  virtualization[:role] = "host"
49
64
  virtualization[:systems][:xen] = "host"
50
65
  end
51
66
  end
52
67
  end
53
68
 
54
- # Xen Notes:
55
- # - cpuid of guests, if we could get it, would also be a clue
56
- # - may be able to determine if under paravirt from /dev/xen/evtchn (See OHAI-253)
57
- # - Additional edge cases likely should not change the above assumptions
58
- # but rather be additive - btm
59
-
60
69
  # Detect Virtualbox from kernel module
61
70
  if File.exist?("/proc/modules")
62
71
  modules = File.read("/proc/modules")
63
72
  if modules =~ /^vboxdrv/
64
- Ohai::Log.debug("Plugin Virtualization: /proc/modules contains vboxdrv. Detecting as vbox host")
73
+ logger.trace("Plugin Virtualization: /proc/modules contains vboxdrv. Detecting as vbox host")
65
74
  virtualization[:system] = "vbox"
66
75
  virtualization[:role] = "host"
67
76
  virtualization[:systems][:vbox] = "host"
68
77
  elsif modules =~ /^vboxguest/
69
- Ohai::Log.debug("Plugin Virtualization: /proc/modules contains vboxguest. Detecting as vbox guest")
78
+ logger.trace("Plugin Virtualization: /proc/modules contains vboxguest. Detecting as vbox guest")
70
79
  virtualization[:system] = "vbox"
71
80
  virtualization[:role] = "guest"
72
81
  virtualization[:systems][:vbox] = "guest"
@@ -75,7 +84,7 @@ Ohai.plugin(:Virtualization) do
75
84
 
76
85
  # if nova binary is present we're on an openstack host
77
86
  if nova_exists?
78
- Ohai::Log.debug("Plugin Virtualization: nova command exists. Detecting as openstack host")
87
+ logger.trace("Plugin Virtualization: nova command exists. Detecting as openstack host")
79
88
  virtualization[:system] = "openstack"
80
89
  virtualization[:role] = "host"
81
90
  virtualization[:systems][:openstack] = "host"
@@ -84,7 +93,7 @@ Ohai.plugin(:Virtualization) do
84
93
  # Detect paravirt KVM/QEMU from cpuinfo, report as KVM
85
94
  if File.exist?("/proc/cpuinfo")
86
95
  if File.read("/proc/cpuinfo") =~ /QEMU Virtual CPU|Common KVM processor|Common 32-bit KVM processor/
87
- Ohai::Log.debug("Plugin Virtualization: /proc/cpuinfo lists a KVM paravirt CPU string. Detecting as kvm guest")
96
+ logger.trace("Plugin Virtualization: /proc/cpuinfo lists a KVM paravirt CPU string. Detecting as kvm guest")
88
97
  virtualization[:system] = "kvm"
89
98
  virtualization[:role] = "guest"
90
99
  virtualization[:systems][:kvm] = "guest"
@@ -96,11 +105,11 @@ Ohai.plugin(:Virtualization) do
96
105
  if File.exist?("/sys/devices/virtual/misc/kvm")
97
106
  virtualization[:system] = "kvm"
98
107
  if File.read("/proc/cpuinfo") =~ /hypervisor/
99
- Ohai::Log.debug("Plugin Virtualization: /sys/devices/virtual/misc/kvm present and /proc/cpuinfo lists the hypervisor feature. Detecting as kvm guest")
108
+ logger.trace("Plugin Virtualization: /sys/devices/virtual/misc/kvm present and /proc/cpuinfo lists the hypervisor feature. Detecting as kvm guest")
100
109
  virtualization[:role] = "guest"
101
110
  virtualization[:systems][:kvm] = "guest"
102
111
  else
103
- Ohai::Log.debug("Plugin Virtualization: /sys/devices/virtual/misc/kvm present and /proc/cpuinfo does not list the hypervisor feature. Detecting as kvm host")
112
+ logger.trace("Plugin Virtualization: /sys/devices/virtual/misc/kvm present and /proc/cpuinfo does not list the hypervisor feature. Detecting as kvm host")
104
113
  virtualization[:role] = "host"
105
114
  virtualization[:systems][:kvm] = "host"
106
115
  end
@@ -109,12 +118,12 @@ Ohai.plugin(:Virtualization) do
109
118
  # Detect OpenVZ / Virtuozzo.
110
119
  # http://wiki.openvz.org/BC_proc_entries
111
120
  if File.exist?("/proc/bc/0")
112
- Ohai::Log.debug("Plugin Virtualization: /proc/bc/0 exists. Detecting as openvz host")
121
+ logger.trace("Plugin Virtualization: /proc/bc/0 exists. Detecting as openvz host")
113
122
  virtualization[:system] = "openvz"
114
123
  virtualization[:role] = "host"
115
124
  virtualization[:systems][:openvz] = "host"
116
125
  elsif File.exist?("/proc/vz")
117
- Ohai::Log.debug("Plugin Virtualization: /proc/vz exists. Detecting as openvz guest")
126
+ logger.trace("Plugin Virtualization: /proc/vz exists. Detecting as openvz guest")
118
127
  virtualization[:system] = "openvz"
119
128
  virtualization[:role] = "guest"
120
129
  virtualization[:systems][:openvz] = "guest"
@@ -123,7 +132,7 @@ Ohai.plugin(:Virtualization) do
123
132
  # Detect Parallels virtual machine from pci devices
124
133
  if File.exist?("/proc/bus/pci/devices")
125
134
  if File.read("/proc/bus/pci/devices") =~ /1ab84000/
126
- Ohai::Log.debug("Plugin Virtualization: /proc/bus/pci/devices contains '1ab84000' pci device. Detecting as parallels guest")
135
+ logger.trace("Plugin Virtualization: /proc/bus/pci/devices contains '1ab84000' pci device. Detecting as parallels guest")
127
136
  virtualization[:system] = "parallels"
128
137
  virtualization[:role] = "guest"
129
138
  virtualization[:systems][:parallels] = "guest"
@@ -134,7 +143,7 @@ Ohai.plugin(:Virtualization) do
134
143
  if File.exist?("/usr/sbin/dmidecode")
135
144
  guest = guest_from_dmi(shell_out("dmidecode").stdout)
136
145
  if guest
137
- Ohai::Log.debug("Plugin Virtualization: dmidecode contains string indicating #{guest} guest")
146
+ logger.trace("Plugin Virtualization: dmidecode contains string indicating #{guest} guest")
138
147
  virtualization[:system] = guest
139
148
  virtualization[:role] = "guest"
140
149
  virtualization[:systems][guest.to_sym] = "guest"
@@ -148,11 +157,11 @@ Ohai.plugin(:Virtualization) do
148
157
  if vxid && vxid[2]
149
158
  virtualization[:system] = "linux-vserver"
150
159
  if vxid[2] == "0"
151
- Ohai::Log.debug("Plugin Virtualization: /proc/self/status contains 's_context' or 'VxID' with a value of 0. Detecting as linux-vserver host")
160
+ logger.trace("Plugin Virtualization: /proc/self/status contains 's_context' or 'VxID' with a value of 0. Detecting as linux-vserver host")
152
161
  virtualization[:role] = "host"
153
162
  virtualization[:systems]["linux-vserver"] = "host"
154
163
  else
155
- Ohai::Log.debug("Plugin Virtualization: /proc/self/status contains 's_context' or 'VxID' with a non-0 value. Detecting as linux-vserver guest")
164
+ logger.trace("Plugin Virtualization: /proc/self/status contains 's_context' or 'VxID' with a non-0 value. Detecting as linux-vserver guest")
156
165
  virtualization[:role] = "guest"
157
166
  virtualization[:systems]["linux-vserver"] = "guest"
158
167
  end
@@ -181,17 +190,17 @@ Ohai.plugin(:Virtualization) do
181
190
  cgroup_content = File.read("/proc/self/cgroup")
182
191
  if cgroup_content =~ %r{^\d+:[^:]+:/(lxc|docker)/.+$} ||
183
192
  cgroup_content =~ %r{^\d+:[^:]+:/[^/]+/(lxc|docker)-?.+$}
184
- Ohai::Log.debug("Plugin Virtualization: /proc/self/cgroup indicates #{$1} container. Detecting as #{$1} guest")
193
+ logger.trace("Plugin Virtualization: /proc/self/cgroup indicates #{$1} container. Detecting as #{$1} guest")
185
194
  virtualization[:system] = $1
186
195
  virtualization[:role] = "guest"
187
196
  virtualization[:systems][$1.to_sym] = "guest"
188
197
  elsif File.read("/proc/1/environ") =~ /container=lxc/
189
- Ohai::Log.debug("Plugin Virtualization: /proc/1/environ indicates lxc container. Detecting as lxc guest")
198
+ logger.trace("Plugin Virtualization: /proc/1/environ indicates lxc container. Detecting as lxc guest")
190
199
  virtualization[:system] = "lxc"
191
200
  virtualization[:role] = "guest"
192
201
  virtualization[:systems][:lxc] = "guest"
193
202
  elsif File.read("/proc/1/environ") =~ /container=systemd-nspawn/
194
- Ohai::Log.debug("Plugin Virtualization: /proc/1/environ indicates nspawn container. Detecting as nspawn guest")
203
+ logger.trace("Plugin Virtualization: /proc/1/environ indicates nspawn container. Detecting as nspawn guest")
195
204
  virtualization[:system] = "nspawn"
196
205
  virtualization[:role] = "guest"
197
206
  virtualization[:systems][:nspawn] = "guest"
@@ -200,7 +209,7 @@ Ohai.plugin(:Virtualization) do
200
209
  # Even so, it is likely we are on an LXC capable host that is not being used as such
201
210
  # So we're cautious here to not overwrite other existing values (OHAI-573)
202
211
  unless virtualization[:system] && virtualization[:role]
203
- Ohai::Log.debug("Plugin Virtualization: /proc/self/cgroup and lxc-version command exist. Detecting as lxc host")
212
+ logger.trace("Plugin Virtualization: /proc/self/cgroup and lxc-version command exist. Detecting as lxc host")
204
213
  virtualization[:system] = "lxc"
205
214
  virtualization[:role] = "host"
206
215
  end
@@ -210,7 +219,7 @@ Ohai.plugin(:Virtualization) do
210
219
  virtualization[:systems][:lxc] = "host"
211
220
  end
212
221
  elsif File.exist?("/.dockerenv") || File.exist?("/.dockerinit")
213
- Ohai::Log.debug("Plugin Virtualization: .dockerenv or .dockerinit exist. Detecting as docker guest")
222
+ logger.trace("Plugin Virtualization: .dockerenv or .dockerinit exist. Detecting as docker guest")
214
223
  virtualization[:system] = "docker"
215
224
  virtualization[:role] = "guest"
216
225
  virtualization[:systems][:docker] = "guest"
@@ -219,13 +228,26 @@ Ohai.plugin(:Virtualization) do
219
228
  # Detect LXD
220
229
  # See https://github.com/lxc/lxd/blob/master/doc/dev-lxd.md
221
230
  if File.exist?("/dev/lxd/sock")
222
- Ohai::Log.debug("Plugin Virtualization: /dev/lxd/sock exists. Detecting as lxd guest")
231
+ logger.trace("Plugin Virtualization: /dev/lxd/sock exists. Detecting as lxd guest")
223
232
  virtualization[:system] = "lxd"
224
233
  virtualization[:role] = "guest"
225
- elsif File.exist?("/var/lib/lxd/devlxd")
226
- Ohai::Log.debug("Plugin Virtualization: /var/lib/lxd/devlxd exists. Detecting as lxd host")
227
- virtualization[:system] = "lxd"
228
- virtualization[:role] = "host"
234
+ else
235
+ # 'How' LXD is installed dictates the runtime data location
236
+ #
237
+ # Installations of LXD from a .deb (Ubuntu's main and backports repos) utilize '/var/lib/lxd/' for runtime data
238
+ # - used by stable releases 2.0.x in trusty/xenial, and 3.0.x in bionic
239
+ # - xenial-backports includes versions 2.1 through 2.21
240
+ #
241
+ # Snap based installations utilize '/var/snap/lxd/common/lxd/'
242
+ # - includes all future releases starting with 2.21, and will be the only source of 3.1+ feature releases post-bionic
243
+ ["/var/lib/lxd/devlxd", "/var/snap/lxd/common/lxd/devlxd"].each do |devlxd|
244
+ if File.exist?(devlxd)
245
+ logger.trace("Plugin Virtualization: #{devlxd} exists. Detecting as lxd host")
246
+ virtualization[:system] = "lxd"
247
+ virtualization[:role] = "host"
248
+ break
249
+ end
250
+ end
229
251
  end
230
252
  end
231
253
  end
@@ -33,7 +33,7 @@ Ohai.plugin(:Lua) do
33
33
  languages[:lua] = lua if lua[:version]
34
34
  end
35
35
  rescue Ohai::Exceptions::Exec
36
- Ohai::Log.debug('Plugin Lua: Could not shell_out "lua -v". Skipping plugin')
36
+ logger.trace('Plugin Lua: Could not shell_out "lua -v". Skipping plugin')
37
37
  end
38
38
  end
39
39
  end
@@ -31,7 +31,7 @@ Ohai.plugin(:Mono) do
31
31
  # Notification: kqueue
32
32
  # Architecture: amd64
33
33
  # Disabled: none
34
- # Misc: softdebug
34
+ # Misc: softtrace
35
35
  # LLVM: supported, not enabled.
36
36
  # GC: sgen
37
37
  if so.exitstatus == 0
@@ -44,7 +44,7 @@ Ohai.plugin(:Mono) do
44
44
  languages[:mono] = mono unless mono.empty?
45
45
  end
46
46
  rescue Ohai::Exceptions::Exec
47
- Ohai::Log.debug('Plugin Mono: Could not shell_out "mono -V". Skipping plugin')
47
+ logger.trace('Plugin Mono: Could not shell_out "mono -V". Skipping plugin')
48
48
  end
49
49
  end
50
50
  end
@@ -76,13 +76,13 @@ Ohai.plugin(:NetworkAddresses) do
76
76
  v[:iface] == network[int_attr]
77
77
  end
78
78
  if gw_if_ips.empty?
79
- Ohai::Log.warn("Plugin Network: [#{family}] no ip address on #{network[int_attr]}")
79
+ logger.warn("Plugin Network: [#{family}] no ip address on #{network[int_attr]}")
80
80
  elsif network[gw_attr] &&
81
81
  network["interfaces"][network[int_attr]] &&
82
82
  network["interfaces"][network[int_attr]]["addresses"]
83
83
  if [ "0.0.0.0", "::", /^fe80:/ ].any? { |pat| pat === network[gw_attr] }
84
84
  # link level default route
85
- Ohai::Log.debug("Plugin Network: link level default #{family} route, picking ip from #{network[gw_attr]}")
85
+ logger.trace("Plugin Network: link level default #{family} route, picking ip from #{network[gw_attr]}")
86
86
  r = gw_if_ips.first
87
87
  else
88
88
  # checking network masks
@@ -91,9 +91,9 @@ Ohai.plugin(:NetworkAddresses) do
91
91
  end.first
92
92
  if r.nil?
93
93
  r = gw_if_ips.first
94
- Ohai::Log.debug("Plugin Network: [#{family}] no ipaddress/mask on #{network[int_attr]} matching the gateway #{network[gw_attr]}, picking #{r[:ipaddress]}")
94
+ logger.trace("Plugin Network: [#{family}] no ipaddress/mask on #{network[int_attr]} matching the gateway #{network[gw_attr]}, picking #{r[:ipaddress]}")
95
95
  else
96
- Ohai::Log.debug("Plugin Network: [#{family}] Using default interface #{network[int_attr]} and default gateway #{network[gw_attr]} to set the default ip to #{r[:ipaddress]}")
96
+ logger.trace("Plugin Network: [#{family}] Using default interface #{network[int_attr]} and default gateway #{network[gw_attr]} to set the default ip to #{r[:ipaddress]}")
97
97
  end
98
98
  end
99
99
  else
@@ -102,7 +102,7 @@ Ohai.plugin(:NetworkAddresses) do
102
102
  end
103
103
  else
104
104
  r = ips.first
105
- Ohai::Log.debug("Plugin Network: [#{family}] no default interface, picking the first ipaddress")
105
+ logger.trace("Plugin Network: [#{family}] no default interface, picking the first ipaddress")
106
106
  end
107
107
 
108
108
  return [ nil, nil ] if r.nil? || r.empty?
@@ -120,7 +120,7 @@ Ohai.plugin(:NetworkAddresses) do
120
120
  # ipaddress: IPAddress
121
121
  # iface: String
122
122
  def network_contains_address(address_to_match, ipaddress, iface)
123
- if peer = network["interfaces"][iface]["addresses"][ipaddress.to_s][:peer]
123
+ if ( peer = network["interfaces"][iface]["addresses"][ipaddress.to_s][:peer] )
124
124
  IPAddress(peer) == IPAddress(address_to_match)
125
125
  else
126
126
  ipaddress.include? IPAddress(address_to_match)
@@ -148,13 +148,13 @@ Ohai.plugin(:NetworkAddresses) do
148
148
  # don't overwrite attributes if they've already been set by the "#{os}::network" plugin
149
149
  if (family == "inet") && ipaddress.nil?
150
150
  if r["ip"].nil?
151
- Ohai::Log.warn("Plugin Network: unable to detect ipaddress")
151
+ logger.warn("Plugin Network: unable to detect ipaddress")
152
152
  else
153
153
  ipaddress r["ip"]
154
154
  end
155
155
  elsif (family == "inet6") && ip6address.nil?
156
156
  if r["ip"].nil?
157
- Ohai::Log.debug("Plugin Network: unable to detect ip6address")
157
+ logger.trace("Plugin Network: unable to detect ip6address")
158
158
  else
159
159
  ip6address r["ip"]
160
160
  end
@@ -164,10 +164,10 @@ Ohai.plugin(:NetworkAddresses) do
164
164
  # otherwise we set macaddress on a first-found basis (and we started with ipv4)
165
165
  if macaddress.nil?
166
166
  if r["mac"]
167
- Ohai::Log.debug("Plugin Network: setting macaddress to '#{r["mac"]}' from interface '#{r["iface"]}' for family '#{family}'")
167
+ logger.trace("Plugin Network: setting macaddress to '#{r["mac"]}' from interface '#{r["iface"]}' for family '#{family}'")
168
168
  macaddress r["mac"]
169
169
  else
170
- Ohai::Log.debug("Plugin Network: unable to detect macaddress for family '#{family}'")
170
+ logger.trace("Plugin Network: unable to detect macaddress for family '#{family}'")
171
171
  end
172
172
  end
173
173
 
@@ -176,7 +176,7 @@ Ohai.plugin(:NetworkAddresses) do
176
176
 
177
177
  if results["inet"]["iface"] && results["inet6"]["iface"] &&
178
178
  (results["inet"]["iface"] != results["inet6"]["iface"])
179
- Ohai::Log.debug("Plugin Network: ipaddress and ip6address are set from different interfaces (#{results["inet"]["iface"]} & #{results["inet6"]["iface"]})")
179
+ logger.trace("Plugin Network: ipaddress and ip6address are set from different interfaces (#{results["inet"]["iface"]} & #{results["inet6"]["iface"]})")
180
180
  end
181
181
  end
182
182
  end
@@ -34,7 +34,7 @@ Ohai.plugin(:Nodejs) do
34
34
  languages[:nodejs] = nodejs if nodejs[:version]
35
35
  end
36
36
  rescue Ohai::Exceptions::Exec
37
- Ohai::Log.debug('Plugin Nodejs: Could not shell_out "node -v". Skipping plugin')
37
+ logger.trace('Plugin Nodejs: Could not shell_out "node -v". Skipping plugin')
38
38
  end
39
39
  end
40
40
  end
@@ -20,8 +20,6 @@ Ohai.plugin(:Ohai) do
20
20
  provides "chef_packages/ohai"
21
21
 
22
22
  collect_data do
23
- require "ohai"
24
-
25
23
  chef_packages Mash.new unless chef_packages
26
24
  chef_packages[:ohai] = Mash.new
27
25
  chef_packages[:ohai][:version] = Ohai::VERSION
@@ -30,24 +30,21 @@ Ohai.plugin(:Openstack) do
30
30
  def openstack_dmi?
31
31
  # detect a manufacturer of OpenStack Foundation
32
32
  if get_attribute(:dmi, :system, :all_records, 0, :Manufacturer) =~ /OpenStack/
33
- Ohai::Log.debug("Plugin Openstack: has_openstack_dmi? == true")
34
- true
35
- elsif get_attribute(:dmi, :system, :product_name) == "OpenStack Compute"
36
33
  logger.trace("Plugin Openstack: has_openstack_dmi? == true")
37
34
  true
38
35
  else
39
- Ohai::Log.debug("Plugin Openstack: has_openstack_dmi? == false")
36
+ logger.trace("Plugin Openstack: has_openstack_dmi? == false")
40
37
  false
41
38
  end
42
39
  end
43
40
 
44
- # check for the ohai hint and log debug messaging
41
+ # check for the ohai hint and log trace messaging
45
42
  def openstack_hint?
46
43
  if hint?("openstack")
47
- Ohai::Log.debug("Plugin Openstack: openstack hint present")
44
+ logger.trace("Plugin Openstack: openstack hint present")
48
45
  true
49
46
  else
50
- Ohai::Log.debug("Plugin Openstack: openstack hint not present")
47
+ logger.trace("Plugin Openstack: openstack hint not present")
51
48
  false
52
49
  end
53
50
  end
@@ -69,12 +66,12 @@ Ohai.plugin(:Openstack) do
69
66
  fetch_metadata.each do |k, v|
70
67
  openstack[k] = v
71
68
  end
72
- Ohai::Log.debug("Plugin Openstack: Successfully fetched Openstack metadata from the metadata endpoint")
69
+ logger.trace("Plugin Openstack: Successfully fetched Openstack metadata from the metadata endpoint")
73
70
  else
74
- Ohai::Log.debug("Plugin Openstack: Timed out connecting to Openstack metadata endpoint. Skipping metadata.")
71
+ logger.trace("Plugin Openstack: Timed out connecting to Openstack metadata endpoint. Skipping metadata.")
75
72
  end
76
73
  else
77
- Ohai::Log.debug("Plugin Openstack: Node does not appear to be an Openstack node")
74
+ logger.trace("Plugin Openstack: Node does not appear to be an Openstack node")
78
75
  end
79
76
  end
80
77
  end
@@ -165,7 +165,7 @@ Ohai.plugin(:Packages) do
165
165
  chunked_lines = so.stdout.lines.map(&:strip).chunk do |line|
166
166
  !line.empty? || nil
167
167
  end
168
- chunked_lines.each do |_, lines|
168
+ chunked_lines.each do |_, lines| # rubocop: disable Performance/HashEachMethods
169
169
  package = {}
170
170
  lines.each do |line|
171
171
  key, value = line.split(":", 2)
@@ -2,6 +2,7 @@
2
2
  Ohai.plugin(:Passwd) do
3
3
  require "etc"
4
4
  provides "etc", "current_user"
5
+ optional true
5
6
 
6
7
  def fix_encoding(str)
7
8
  str.force_encoding(Encoding.default_external) if str.respond_to?(:force_encoding)
@@ -39,7 +39,7 @@ Ohai.plugin(:Perl) do
39
39
  languages[:perl] = perl unless perl.empty?
40
40
  end
41
41
  rescue Ohai::Exceptions::Exec
42
- Ohai::Log.debug('Plugin Perl: Could not shell_out "perl -V:version -V:archname". Skipping plugin')
42
+ logger.trace('Plugin Perl: Could not shell_out "perl -V:version -V:archname". Skipping plugin')
43
43
  end
44
44
  end
45
45
  end
@@ -46,7 +46,7 @@ Ohai.plugin(:PHP) do
46
46
  languages[:php] = php unless php.empty?
47
47
  end
48
48
  rescue Ohai::Exceptions::Exec
49
- Ohai::Log.debug('Plugin Php: Could not shell_out "php -v". Skipping plugin')
49
+ logger.trace('Plugin Php: Could not shell_out "php -v". Skipping plugin')
50
50
  end
51
51
  end
52
52
  end
@@ -51,7 +51,7 @@ Ohai.plugin(:Powershell) do
51
51
  languages[:powershell] = powershell unless powershell.empty?
52
52
  end
53
53
  rescue Ohai::Exceptions::Exec
54
- Ohai::Log.debug('Plugin Powershell: Could not shell_out "powershell.exe -NoLogo -NonInteractive -NoProfile -command $PSVersionTable". Skipping plugin')
54
+ logger.trace('Plugin Powershell: Could not shell_out "powershell.exe -NoLogo -NonInteractive -NoProfile -command $PSVersionTable". Skipping plugin')
55
55
  end
56
56
  end
57
57
 
@@ -37,7 +37,7 @@ Ohai.plugin(:Python) do
37
37
  languages[:python] = python unless python.empty?
38
38
  end
39
39
  rescue Ohai::Exceptions::Exec
40
- Ohai::Log.debug('Plugin Python: Could not shell_out "python -c "import sys; print (sys.version)"". Skipping plugin')
40
+ logger.trace('Plugin Python: Could not shell_out "python -c "import sys; print (sys.version)"". Skipping plugin')
41
41
  end
42
42
  end
43
43
  end