0

I have a wapper cookbook that contains a custom ohai plugin. This plugin is used in my second cookbook. Is my config.rb file correct?

cookbook_path [
    '/home/user/.chef/cookbooks',   #<< ohai cookbook
    '/home/user/cookbooks'          #<< wrapper cookbook (ohai plugin) and second cookbook
]

ohai.plugin_path += [
   '/home/user/cookbooks/ohai/plugins'
]

ohai.directory '/home/user/cookbooks/ohai/plugins'

Is it necessary that the wrapper cookbook with the ohai plugin is in the run-list before the second cookbook?

UPDATE:

When I update my custom ohai plugin attribute and run the chef-client, the updated ohai plugin is copied to the specified location /etc/chef/ohai/plugins but the log information shows still the previous value.

include_recipe 'ohai'

ohai 'reload' do
  plugin 'example'
  action :nothing
end

cookbook_file "#{node['ohai']['plugin_path']}/example.rb" do
  source 'example.rb'
  notifies :reload, 'ohai[reload]', :immediately
end

test = "#{node['ohai']['example']}"
log test 
user5580578
  • 1,134
  • 1
  • 12
  • 28

1 Answers1

0

use ohai resource to load the custom plugin.

Mr.
  • 9,429
  • 13
  • 58
  • 82
  • Thanks for the hint. At the moment the attribute value from my custom ohai plugin will be only updated with the second chef-run – user5580578 Mar 30 '20 at 13:08