[英]Ohai plugin_path not being loaded on Windows 10
Following Ron Cowie's guide in his book Customising Chef (O'Reilly) to creating simple Ohai plugin, it appears as though the Ohai plugins_path is not being loaded on my Windows 10 laptop. 继Ron Cowie在他的书Customizing Chef(O'Reilly)创建简单的Ohai插件之后,看起来似乎没有在我的Windows 10笔记本电脑上加载Ohai plugins_path。
Steps are as follows: 步骤如下:
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={},...
It looks to me as though the @plugin_path is empty and so after running o.all_plugins and then o.attributes_print("awesome_level") 它看起来好像@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!)
Is it syntax for setting the plugins_path on Windows. 是在Windows上设置plugins_path的语法。 I tried double-quotes.
我试过双引号。 Backslashes.
反斜杠。
My Chef install is not standard and the default C:\\chef\\ohai\\plugins folder did not exist. 我的Chef安装不是标准的,默认的C:\\ chef \\ ohai \\ plugins文件夹不存在。 If i used cmd line to add a directory to plugin path it worked:
如果我使用cmd行将目录添加到插件路径它工作:
ohai -d 'C:\\dev\\opscode\\ohai\\plugins'
ohai -d'C:\\ dev \\ opscode \\ ohai \\ plugins'
This displayed all attributes from all plugins with right at the end my custom plugin 这显示了我的自定义插件的所有插件的所有属性
}, "awesome_level": 100
},“awesome_level”:100
feels to me like you suffer from versioning issue -- to resolve any path and version issues, use bundler
and lock your rubygems versions in a Gemfile
. 感觉就像你遇到版本问题 - 解决任何路径和版本问题,使用
bundler
并在Gemfile
锁定你的rubygems 版本 。
here is an example: 这是一个例子:
$ 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
...
you mentioned that you are using chef . 你提到你正在使用厨师 。 if you use ohai within chef-client run, then the plugin must be installed on the node that is managed by chef and before ohai is being load up in your recipe.
如果你在chef-client run中使用ohai,那么插件必须安装在由chef管理的节点上,并且在你的配方中加载ohai之前。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.