[英]Ohai plugin_path not being loaded on Windows 10
繼Ron Cowie在他的書Customizing Chef(O'Reilly)創建簡單的Ohai插件之后,看起來似乎沒有在我的Windows 10筆記本電腦上加載Ohai plugins_path。
步驟如下:
Ohai.plugin(:Example1) do 1 provides "awesome_level" 2 collect_data do 3 awesome_level 100 4 end end
PS C:\\WINDOWS\\system32> irb irb(main):001:0> require '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 => #<Ohai::System:0x0000000003c339a0 @cli=nil, @plugin_path="", @config={},...
它看起來好像@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的語法。 我試過雙引號。 反斜杠。
我的Chef安裝不是標准的,默認的C:\\ chef \\ ohai \\ plugins文件夾不存在。 如果我使用cmd行將目錄添加到插件路徑它工作:
ohai -d'C:\\ dev \\ opscode \\ ohai \\ plugins'
這顯示了我的自定義插件的所有插件的所有屬性
},“awesome_level”:100
感覺就像你遇到版本問題 - 解決任何路徑和版本問題,使用bundler
並在Gemfile
鎖定你的rubygems 版本 。
這是一個例子:
$ 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
...
你提到你正在使用廚師 。 如果你在chef-client run中使用ohai,那么插件必須安裝在由chef管理的節點上,並且在你的配方中加載ohai之前。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.