简体   繁体   English

在 irb shell 中调试 Ohai 插件

[英]Debug Ohai plugins in irb shell

I've installed a chef-workstation on my computer.我在我的电脑上安装了一个厨师工作站。

 ohai --version #returns: 15.7.4

I also installed the Ohai cookbook from the supermarket.我还安装了超市的 Ohai 食谱。 If I integrate this into my test cookbook, the self-written Ohai plug-in will be executed as expected.如果我将其集成到我的测试手册中,那么自编的 Ohai 插件将按预期执行。

Now I want to try to use Ruby现在我想尝试使用 Ruby

s "irb" shell to debug the self-written ohai plugin step by step. 

Unfortunately 

    irb
    > require 'ohai'  # ==> true
    > Ohai::Config[:plugin_path] << '/home/ohai_plugins'

produces the error message "LoadError (NoMethodError (undefined method <<' for nil:NilClass)". When I use产生错误消息“LoadError (NoMethodError (undefined method <<' for nil:NilClass)”。当我使用

>  Ohai::Config[:plugin_path] = '/home/ohai_plugins'
>  #=> "/home/ohai_plugins"

it seems to work.它似乎工作。 But installing the system shows that there is no plugin_path installed...但是安装系统显示没有plugin_path安装...

> o = Ohai::System.new
> #<Ohai::System:0x000055a67d5055b8 @cli=nil, @plugin_path="", @config={}

When I try to get further the attribute from my test Ohai plugin can not be found.当我尝试从我的测试 Ohai 插件中进一步获取属性时,无法找到。

> o.all_plugins
> o.attributes_print("awesome_level") 
> #ArgumentError (I cannot find an attribute named awesome_level!)

try the following尝试以下

require 'ohai'
Ohai::Config[:plugin_path] << '/home/ohai_plugins'
ohai = Ohai::System.new
ohai.all_plugins

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM