- From: Douglas Land <
>
- To:
- Subject: [chef] Re: Re: Re: Issues with creating an ohai plugin
- Date: Tue, 29 Jan 2013 22:53:35 -0600
John,
You're absolutely right and as a matter of fact I have both in that
recipe as I copied a bad version up, but here's the current one I just
re-pushed:
https://github.com/looprock/ohai_plugins/blob/master/customjava.rb
Charles,
Hey man, damn I knew there was someone else I should have been asking
about this. :) I'm pretty sure it's loading. Here's the relevant INFO
output from the client.log:
[2013-01-30T02:35:48+01:00] INFO: *** Chef 10.16.2 ***
[2013-01-30T02:35:49+01:00] INFO: Run List is
[recipe[vast-rundeck-users], role[vastbase], recipe[ohai],
recipe[zabbix], recipe[vast-installrvm]]
[2013-01-30T02:35:49+01:00] INFO: Run List expands to
[vast-rundeck-users, vast-ntp, vast-chef-client, ohai, zabbix,
vast-installrvm]
[2013-01-30T02:35:49+01:00] INFO: HTTP Request Returned 404 Not Found:
No routes match the request: /reports/nodes/cheftest.vast.com/runs
[2013-01-30T02:35:49+01:00] INFO: Starting Chef Run for cheftest.vast.com
[2013-01-30T02:35:49+01:00] INFO: Running start handlers
[2013-01-30T02:35:49+01:00] INFO: Start handlers complete.
[2013-01-30T02:35:49+01:00] INFO: Loading cookbooks [apache2, aws,
build-essential, database, firewall, mysql, ohai, openssl, postgresql,
ufw, vast-chef-client, vast-installrvm, vast-ntp, vast-rundeck-users,
xfs, yum, zabbix]
[2013-01-30T02:35:49+01:00] WARN: Missing gem 'right_aws'
[2013-01-30T02:35:49+01:00] INFO: ohai plugins will be at:
/etc/chef/ohai_plugins
[2013-01-30T02:35:49+01:00] INFO: Processing
remote_directory[/etc/chef/ohai_plugins] action create (ohai::default
line 27)
[2013-01-30T02:35:49+01:00] INFO: Processing
cookbook_file[/etc/chef/ohai_plugins/customjava.rb] action create
(dynamically defined)
[2013-01-30T02:35:49+01:00] INFO:
cookbook_file[/etc/chef/ohai_plugins/customjava.rb] backed up to
/var/chef/backup/etc/chef/ohai_plugins/customjava.rb.chef-20130130023549
[2013-01-30T02:35:49+01:00] INFO:
cookbook_file[/etc/chef/ohai_plugins/customjava.rb] removed backup at
/var/chef/backup/./etc/chef/ohai_plugins/customjava.rb.chef-20130129215618
[2013-01-30T02:35:49+01:00] INFO:
cookbook_file[/etc/chef/ohai_plugins/customjava.rb] owner changed to 0
[2013-01-30T02:35:49+01:00] INFO:
cookbook_file[/etc/chef/ohai_plugins/customjava.rb] group changed to 0
[2013-01-30T02:35:49+01:00] INFO:
cookbook_file[/etc/chef/ohai_plugins/customjava.rb] mode changed to
644
[2013-01-30T02:35:49+01:00] INFO:
cookbook_file[/etc/chef/ohai_plugins/customjava.rb] created file
/etc/chef/ohai_plugins/customjava.rb
[2013-01-30T02:35:49+01:00] INFO: Processing
cookbook_file[/etc/chef/ohai_plugins/README] action create
(dynamically defined)
[2013-01-30T02:35:49+01:00] INFO: Processing ohai[custom_plugins]
action reload (ohai::default line 42)
[2013-01-30T02:35:50+01:00] INFO: ohai[custom_plugins] reloaded
...
[2013-01-30T02:35:53+01:00] INFO: Processing ohai[custom_plugins]
action nothing (ohai::default line 42)
...
[2013-01-30T02:35:54+01:00] INFO: Chef Run complete in 5.092088632 seconds
[2013-01-30T02:35:54+01:00] INFO: Running report handlers
[2013-01-30T02:35:54+01:00] INFO: Report handlers complete
client.rb:
log_level :info
log_location STDOUT
chef_server_url '
http://chef.server.com:4000'
validation_client_name 'chef-validator'
Ohai::Config[:plugin_path] << '/etc/chef/ohai_plugins'
~]# /opt/chef/embedded/bin/irb
irb(main):001:0> require 'ohai'
=> true
irb(main):002:0> Ohai::Config[:plugin_path] << '/etc/chef/ohai_plugins'
=>
["/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/ohai-6.14.0/lib/ohai/plugins",
"/etc/chef/ohai_plugins"]
irb(main):003:0> o = Ohai::System.new
=> #<Ohai::System:0x00000000cf4a90 @data={}, @seen_plugins={},
@providers={}, @plugin_path="", @hints={}>
irb(main):004:0> o.all_plugins
=> true
irb(main):005:0> o.seen_plugins
=> {"os"=>true, "kernel"=>true, "ruby"=>true, "languages"=>true,
"network"=>true, "hostname"=>true, "linux::hostname"=>true,
"linux::network"=>true, "dmi"=>true, "ohai"=>true,
"virtualization"=>true, "linux::virtualization"=>true, "cloud"=>true,
"ec2"=>true, "rackspace"=>true, "eucalyptus"=>true, "passwd"=>true,
"c"=>true, "groovy"=>true, "command"=>true, "keys"=>true,
"dmi_common"=>true, "perl"=>true, "network_listeners"=>true,
"java"=>true, "python"=>true, "ip_scopes"=>true, "lua"=>true,
"php"=>true, "chef"=>true, "mono"=>true, "uptime"=>true,
"ohai_time"=>true, "platform"=>true, "linux::platform"=>true,
"linux::lsb"=>true, "erlang"=>true, "linux::cpu"=>true,
"linux::memory"=>true, "linux::ssh_host_key"=>true,
"linux::block_device"=>true, "linux::ps"=>true,
"linux::filesystem"=>true, "linux::uptime"=>true,
"linux::kernel"=>true, "customjava"=>true}
irb(main):006:0> o.customjava
=> nil
There are a few exceptions, but this seems me like it's chef looking
in the default path before the path added in
Ohai::Config[:plugin_path] << '/etc/chef/ohai_plugins':
[2013-01-30T05:41:13+01:00] DEBUG: Loading plugin customjava
[2013-01-30T05:41:13+01:00] DEBUG: Plugin customjava threw exception
#<IOError: Cannot open or read
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/ohai-6.14.0/lib/ohai/plugins/customjava.rb!>
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/ohai-6.14.0/lib/ohai/mixin/from_file.rb:31:in
`from_file'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/ohai-6.14.0/lib/ohai/system.rb:215:in
`block in require_plugin'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/ohai-6.14.0/lib/ohai/system.rb:210:in
`each'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/ohai-6.14.0/lib/ohai/system.rb:210:in
`require_plugin'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/ohai-6.14.0/lib/ohai/system.rb:139:in
`block (2 levels) in all_plugins'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/ohai-6.14.0/lib/ohai/system.rb:132:in
`each'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/ohai-6.14.0/lib/ohai/system.rb:132:in
`block in all_plugins'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/ohai-6.14.0/lib/ohai/system.rb:130:in
`each'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/ohai-6.14.0/lib/ohai/system.rb:130:in
`all_plugins'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.16.2/lib/chef/client.rb:215:in
`run_ohai'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.16.2/lib/chef/client.rb:405:in
`do_run'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.16.2/lib/chef/client.rb:176:in
`run'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.16.2/lib/chef/application.rb:140:in
`run_chef_client'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.16.2/lib/chef/application/client.rb:274:in
`block in run_application'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.16.2/lib/chef/application/client.rb:267:in
`loop'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.16.2/lib/chef/application/client.rb:267:in
`run_application'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.16.2/lib/chef/application.rb:72:in
`run'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.16.2/bin/chef-client:26:in
`<top (required)>'
/usr/bin/chef-client:23:in `load'
/usr/bin/chef-client:23:in `<main>'
[2013-01-30T05:41:13+01:00] DEBUG: Loading plugin customjava
…
[2013-01-30T05:41:14+01:00] INFO: Processing
cookbook_file[/etc/chef/ohai_plugins/customjava.rb] action create
(dynamically defined)
…
[2013-01-30T05:41:14+01:00] DEBUG: Loading plugin customjava
[2013-01-30T05:41:14+01:00] DEBUG: Plugin customjava threw exception
#<IOError: Cannot open or read
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/ohai-6.14.0/lib/ohai/plugins/customjava.rb!>
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/ohai-6.14.0/lib/ohai/mixin/from_file.rb:31:in
`from_file'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/ohai-6.14.0/lib/ohai/system.rb:215:in
`block in require_plugin'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/ohai-6.14.0/lib/ohai/system.rb:210:in
`each'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/ohai-6.14.0/lib/ohai/system.rb:210:in
`require_plugin'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/ohai-6.14.0/lib/ohai/system.rb:139:in
`block (2 levels) in all_plugins'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/ohai-6.14.0/lib/ohai/system.rb:132:in
`each'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/ohai-6.14.0/lib/ohai/system.rb:132:in
`block in all_plugins'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/ohai-6.14.0/lib/ohai/system.rb:130:in
`each'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/ohai-6.14.0/lib/ohai/system.rb:130:in
`all_plugins'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.16.2/lib/chef/provider/ohai.rb:39:in
`block in action_reload'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.16.2/lib/chef/mixin/why_run.rb:63:in
`call'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.16.2/lib/chef/mixin/why_run.rb:63:in
`block in converge!'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.16.2/lib/chef/mixin/why_run.rb:61:in
`each'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.16.2/lib/chef/mixin/why_run.rb:61:in
`converge!'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.16.2/lib/chef/provider.rb:136:in
`converge'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.16.2/lib/chef/provider.rb:125:in
`run_action'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.16.2/lib/chef/resource.rb:593:in
`run_action'
/var/chef/cache/cookbooks/ohai/recipes/default.rb:51:in `from_file'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.16.2/lib/chef/mixin/from_file.rb:30:in
`instance_eval'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.16.2/lib/chef/mixin/from_file.rb:30:in
`from_file'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.16.2/lib/chef/cookbook_version.rb:558:in
`load_recipe'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.16.2/lib/chef/mixin/language_include_recipe.rb:46:in
`load_recipe'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.16.2/lib/chef/mixin/language_include_recipe.rb:33:in
`block in include_recipe'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.16.2/lib/chef/mixin/language_include_recipe.rb:27:in
`each'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.16.2/lib/chef/mixin/language_include_recipe.rb:27:in
`include_recipe'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.16.2/lib/chef/run_context.rb:79:in
`block in load'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.16.2/lib/chef/run_context.rb:75:in
`each'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.16.2/lib/chef/run_context.rb:75:in
`load'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.16.2/lib/chef/client.rb:198:in
`setup_run_context'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.16.2/lib/chef/client.rb:418:in
`do_run'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.16.2/lib/chef/client.rb:176:in
`run'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.16.2/lib/chef/application.rb:140:in
`run_chef_client'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.16.2/lib/chef/application/client.rb:274:in
`block in run_application'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.16.2/lib/chef/application/client.rb:267:in
`loop'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.16.2/lib/chef/application/client.rb:267:in
`run_application'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.16.2/lib/chef/application.rb:72:in
`run'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.16.2/bin/chef-client:26:in
`<top (required)>'
/usr/bin/chef-client:23:in `load'
/usr/bin/chef-client:23:in `<main>'
[2013-01-30T05:41:14+01:00] DEBUG: Loading plugin customjava
On Tue, Jan 29, 2013 at 5:08 PM, Charles Sullivan
<
>
wrote:
>
Doug! What is up man. Glad to see you're using Chef.
>
>
Are you sure that ohai_plugins are being processed on the server you're
>
running chef-client on? I believe you need the ohai recipe in your runlist.
>
Send us the output from your chef-client debug log..
>
>
--Charlie
>
>
>
On Tue, Jan 29, 2013 at 4:56 PM, John Alberts
>
<
>
>
wrote:
>
>
>
> I'm not sure if this matters, but the examples all use symbols instead of
>
> strings for the keys and I've always used symbols as well. I notice you
>
> have: customjava["java_home"] and customjava["result"].
>
>
>
> John
>
>
>
>
>
> On Tue, Jan 29, 2013 at 4:36 PM, Douglas Land
>
> <
>
>
> wrote:
>
>>
>
>> Hi all,
>
>>
>
>> I apologize in advance because I'm guessing this is something dumb as
>
>> I'm pretty green to ruby. I'm trying to create a custom ohai plugin.
>
>> I've looked at examples and can't for the life of me figure out what
>
>> I'm doing wrong here:
>
>>
>
>> https://github.com/looprock/ohai_plugins/blob/master/customjava.rb
>
>>
>
>> When I try to query this I get:
>
>>
>
>> knife node show cheftest.vast.com -a customjava -Fj
>
>> {
>
>> "customjava": null
>
>> }
>
>>
>
>> Any help would be greatly appreciated.
>
>
>
>
>
>
>
>
>
> --
>
> John Alberts
>
>
>
>
>
--
>
Charles Sullivan
>
Archive powered by MHonArc 2.6.16.