-
Notifications
You must be signed in to change notification settings - Fork 3
Feature/RFC: Remote Ohai Info #21
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Aaron Lippold <[email protected]>
Code for setting up an Ohai target to run is as follows: require 'ohai'
PLUGINS = %w{
cpu
kernel
os
platform}.freeze
ohai_test = Ohai::System.new
Ohai::Config.target_mode.host = 'docker://<somehost>'
if URI.parse(Ohai::Config.target_mode.host).scheme
train_config = Train.unpack_target_from_uri(Ohai::Config.target_mode.host)
Ohai::Config.target_mode = train_config
end
Ohai::Config.target_mode.enabled = true
Ohai::Config.node_name = Ohai::Config.target_mode.host unless Ohai::Config.node_name
ohai_test.tap { |o| o.all_plugins(PLUGINS) }.data This will cause remote ohai to throw a fit since https://github.com/chef/chef/blob/main/chef-config/lib/chef-config/mixin/train_transport.rb#L72-L100 expects a config file to exist. It is very weird that a config file is expected to exist considering Inspec handles train credentials as follows: https://github.com/inspec/inspec/blob/7415fc11d000dae1813a14ba12d957851fa999b3/lib/inspec/config.rb#L109-L128 |
Thanks, that summarizes things nicely. So the Also, hi Rob. 👋 |
if URI.parse(Ohai::Config.target_mode.host).scheme
train_config = Train.unpack_target_from_uri(Ohai::Config.target_mode.host)
Ohai::Config.target_mode = train_config
end @rbclark are we sure this is the right block here? It seems to be throwing a new error we didn't see before: [2] pry(main)> next
Traceback (most recent call last):
11: from ohai.rb:17:in `<main>'
10: from ohai.rb:17:in `tap'
9: from ohai.rb:17:in `block in <main>'
8: from /Users/alippold/.rvm/gems/ruby-2.7.2/gems/ohai-17.9.0/lib/ohai/system.rb:105:in `all_plugins'
7: from /Users/alippold/.rvm/gems/ruby-2.7.2/gems/ohai-17.9.0/lib/ohai/system.rb:130:in `run_plugins'
6: from /Users/alippold/.rvm/gems/ruby-2.7.2/gems/ohai-17.9.0/lib/ohai/system.rb:130:in `each'
5: from /Users/alippold/.rvm/gems/ruby-2.7.2/gems/ohai-17.9.0/lib/ohai/system.rb:131:in `block in run_plugins'
4: from /Users/alippold/.rvm/gems/ruby-2.7.2/gems/ohai-17.9.0/lib/ohai/system.rb:83:in `runner'
3: from /Users/alippold/.rvm/gems/ruby-2.7.2/gems/ohai-17.9.0/lib/ohai/system.rb:83:in `tap'
2: from /Users/alippold/.rvm/gems/ruby-2.7.2/gems/ohai-17.9.0/lib/ohai/system.rb:84:in `block in runner'
1: from /Users/alippold/.rvm/gems/ruby-2.7.2/gems/ohai-17.9.0/lib/ohai/system.rb:119:in `transport_connection'
/Users/alippold/.rvm/gems/ruby-2.7.2/gems/chef-config-17.9.52/lib/chef-config/mixin/train_transport.rb:115:in `build_transport': undefined method `[]' for nil:NilClass (NoMethodError) |
https://docs.chef.io/workstation/knife_setup/ - chef credentials file |
Hey AJ! Yep, so |
@aaronlippold should we catch up this week or next to sync up on this stuff? |
Would love to |
General Goal
Enhance our reporter plugin and add a new core plugin to inspec that will use the new Ohai remote target mode and the existing train connection to the target to populate a new section of the
run_data
in inspec which will support adding a top-level.target
object in the JSON base reporter to collect inventory information about the asset under test.References
Approach
Notes from Conversation with @cwolf on topic
This PR should be split into two parts.
attestation
function and just having the new ohai dataFollow On Work
make all reporters plugins
, add acli-options
plug-in type, etc.Part (1)
run_data
object for use in other reporters.--without-ohai
and--ohai-plugins=<list>
to over-ride the default filters.automate
reporterjson reporter
calledtarget
that holds the new data.Part (2)
(a) Update the hdf reporter to use the new
run_data
from ohai and itstarget-specific
data(b) Merge the hdf reporter into core as an Attestation PR next to waiver and update our technical implemation to follow closely with waiver
This approach would allow us to know which transport we are using and then – if a specific Ohai plugin exists for that target – ec2, vmware, docker etc. – we could active it and pass the information about through to the final report.
Part (3)
(Part 4) Longer Tearm Solution
A
cli-options plugin
type would be the best way to approach this however, @cwolf said things are a bit of mess at the moment so this is likely the only real viable approach at the moment.Then the HDF reporter or any reporter could just check for the existance of the OHAI data in the
run_data
object and layer it in if it is there.Questions / Workflow
Signed-off-by: Aaron Lippold [email protected]