chef recipe doesn't find ohai plugin defined resource -


i want add additional resource 'version of installed openssh' ohai use in openssh maintaining recipe.

on rhel 5.11 chef 12.4.1 ohai 8.5.0 test workstation have created , tested ohai plugin

$ cat cookbooks/test/files/default/plugins/openssh.rb

ohai.plugin(:openssh)    provides "openssh"  ohai::log.debug('plugin start')    def create_objects      openssh mash.new    end     collect_data      create_objects      openssh[:version] = 'ssh -v 2>&1 |head -1| cut -d, -f1| cut -d_ -f2 '    end  end 

local test of ohai plugin in irb working fine. i'm trying check resource visibility in chef recipe

$ cat test/recipes/default.rb

file "#{env['home']}/x.txt"    content 'hello world'  end  output="#{chef::jsoncompat.to_json_pretty(node.to_hash)}"  file '/tmp/node.json'    content output  end  chef::log.info("============ test cookbook ** #{openssh['version']} **")  \#chef::log.info("============ test cookbook ** #{node['kernel']} **") 

by running local chef-client

$ chef-client -z -m test/recipes/default.rb

to make additional plugin visible line added config files

$grep ohai ~/.chef/*.rb ~/.chef/client.rb:ohai::config[:plugin_path] << '~/chef/cookbooks/test/files/default/plugins/'  ~/.chef/knife.rb:ohai::config[:plugin_path] << '~/chef/cookbooks/test/files/default/plugins/' 

(i understand explicit )

although running printing node['kernel'] working fine , openssh version not running debug log shows:

[2016-01-27t11:48:21-08:00] debug: cookbooks detail: []  [2016-01-27t11:48:21-08:00] debug: cookbooks compile: []  [2016-01-27t11:48:21-08:00] debug: **loading recipe file xxx/cookbooks/test/recipes/default.rb**  [2016-01-27t11:48:21-08:00] debug: resources generic file resource enabled on node include: [chef::resource::file]  [2016-01-27t11:48:21-08:00] debug: resource file chef::resource::file  [2016-01-27t11:48:21-08:00] debug: resources generic file resource enabled on node include: [chef::resource::file]  [2016-01-27t11:48:21-08:00] debug: resource file chef::resource::file  [2016-01-27t11:48:21-08:00] debug: resources generic openssh resource enabled on node include: []  [2016-01-27t11:48:21-08:00] debug: **dynamic resource resolver failed resolve resource openssh**  [2016-01-27t11:48:21-08:00] debug: re-raising exception: nameerror - no resource, method, or local variable named `openssh' `chef::recipe "xxx/cookbooks/test/recipes/default.rb"' 

questions:

  1. how chef out additional plugin recipe local , remote execution? how check cheffed out , ready?

  2. how notify chef-client execute ohai additional plugin local single recipe run , remote run well?

any explanations , suggestions welcomed.

alex

a few issues: first check out https://github.com/coderanger/ohai-example see how package ohai plugin in cookbook distribution. second, node attributes custom plugins still need accessed via node object: node['openssh']['version']. third, remember how execution ordering works in chef (https://coderanger.net/two-pass/) , custom attributes won't available until after plugin loaded , run.


Comments

Popular posts from this blog

authentication - Mongodb revoke acccess to connect test database -

r - Update two sets of radiobuttons reactively - shiny -

ios - Realm over CoreData should I use NSFetchedResultController or a Dictionary? -