user5580578
user5580578

Reputation: 1334

order of cookbooks in run-list using a custom ohai plugin

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 

Upvotes: 0

Views: 140

Answers (1)

Mr.
Mr.

Reputation: 10122

use ohai resource to load the custom plugin.

Upvotes: 0

Related Questions