【问题标题】:Debug Ohai plugins in irb shell在 irb shell 中调试 Ohai 插件
【发布时间】:2020-03-27 10:02:51
【问题描述】:

我已经在我的电脑上安装了一个厨师工作站。

 ohai --version #returns: 15.7.4

我还从超市安装了 Ohai 食谱。如果我把它集成到我的测试说明书中,自写的 Ohai 插件将按预期执行。

现在我想尝试使用 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'

产生错误消息“LoadError (NoMethodError (undefined method

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

它似乎工作。但是安装系统显示没有安装plugin_path...

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

当我尝试进一步从我的测试 Ohai 插件中获取属性时,找不到。

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

【问题讨论】:

    标签: chef-infra irb ohai-gem


    【解决方案1】:

    试试下面的

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-08-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-09-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多