按照Following在他的书“定制厨师(O‘’Reilly)”中关于创建简单Ohai插件的指导,似乎Ohai plugins_path并没有加载到我的Windows10笔记本上。
步骤如下:
Ohai.plugin(:Example1) do 1提供" awesome_level“2 collect_data do 3 awesome_level 100 4末端
C:\WINDOWS\system32> irb(main):001:0>要求'ohai‘=> true irb(main):002:0> Ohai::Config:plugin_path = 'C:/Dev/opscode/ohai/plugins’=>‘C:/Dev/opscode/ohai/plugins“irb(main):003:0> o= Ohai::System.new => #
在我看来,@plugin_path似乎是空的,所以在运行o.all_plugins和o.attributes_print之后(“awesome_level”)
> Results in error: irb(main):019:0> puts
> o.attributes_print("awesome_level") Traceback (most recent call last):
> 3: from C:/opscode/chef-workstation/embedded/bin/irb.cmd:19:in `<main>'
> 2: from (irb):19
> 1: from C:/opscode/chef-workstation/embedded/lib/ruby/gems/2.5.0/gems/ohai-14.8.10/lib/ohai/system.rb:178:in
> `attributes_print' ArgumentError (I cannot find an attribute named
> awesome_level!)是用于在Windows上设置plugins_path的语法吗?我试过双引号。反斜杠。
发布于 2019-03-22 11:42:32
我的厨师安装是不标准的,默认的C:\厨师\ohai\plugins文件夹不存在。如果我使用cmd行将一个目录添加到插件路径,它就能工作:
ohai -d 'C:\dev\opscode\ohai\plugins‘
这显示了所有插件的所有属性,并在我的自定义插件的末尾显示了所有属性。
},"awesome_level":100
发布于 2019-03-23 14:25:41
对我来说,我觉得您遇到了版本控制问题--要解决任何路径和版本问题,请使用bundler并将您的红宝石 版本锁定在Gemfile中。
以下是一个例子:
$ bundle init
Writing new Gemfile to /private/var/folders/_2/rg7rz1h56sb2ln5f75gjr7558b1wz3/T/tmp.PPIvZRXi/Gemfile
$ echo "gem 'ohai'" >> Gemfile
$ bundle install --path vendor/gems --jobs 4
...您提到您正在使用大厨。如果在主厨-客户端运行中使用ohai,则必须在厨师管理的节点上安装插件,然后再将ohai加载到您的菜谱中。
https://stackoverflow.com/questions/55296991
复制相似问题