ruby - Meet "uninitialized constant #::Chef::Resource::CookbookFile" when running chef-client -
<< Html>
I am using chef 11.10.0.
I apply a new resource named MicroBox that receives the Chef:: Resource :: Cookbook.
And, I'm not going to change the provider at this moment (then Chef :: Provider :: CookbookFile will be used).
'Chef / Resources / cookbook_file' is required 'Chef / Mixin / Secure' Category Chef Class Resource Category MyCookbookFile & lt; Chef :: Resources :: Cookbook File: Chef :: Mixin :: Secure provides: my_cookbook_file ,: on_platforms = & gt; : All # more codes here ... end end I got the following error:
============ ================================================== ================== Recipe /var/chef/cache/cookbooks/my-cookbook/resources/my_cookbook_file.rb ======== Compilation Error ================================================= ====================== NameError --------- Initialized continuous # & lt; Class: 0x8d78f18 & gt; :: Chef :: Resources :: CookbookFile Cookbook Trace: --------------- /var/chef/cache/cookbooks/my-cookbook/resources/my_cookbook_file.rb:6: In & lt; Category: Resources & gt; '/var/chef/cache/cookbooks/my-cookbook/resources/my_cookbook_file.rbitter:in `& lt; Category: Chef & gt; '/var/chef/cache/cookbooks/my-cookbook/resources/my_cookbook_file.rb: 4: in` class_from_file' Relevant file content: -------------------- - - /var/chef/cache/cookbooks/my-cookbook/resources/my_cookbook_file.rb: 1: 'chef / resource / cookbook_file' required 2: 'chef / mixin / secure' required 3: 4 : Class Chef 5: Classroom Resources 6 & gt; & Gt; Class MyCookbookFile & lt; Chef :: Resources :: CookbookFile Running Operators: [2014-02-17T08: 16: 26 + 00: 00] Error: Running Exception Operators Running Full Operators [2014-02-17T08: 16: 26 + 00: 00] Error: Exception handlers complete [2014-02-17T08: 16: 26 + 00: 00] FATAL: Chef client left in stacktrace /var/chef/cache/chef-stacktrace.out failed. Updated in 1.18243344 seconds in 0 resources [2014-02-17T08: 16: 26 + 00: 00] Error: Undefined Continous # & lt; Category: 0x8d78f18 & gt; :: Chef :: Resources :: CookbookFile [2014-02-17T08: 16: 26 + 00: 00] FATAL: Chef :: Exception :: ChildConverse Error: Chef Run Process Has Failed (exit code 1) I tried to print and check LOAD_PATH in my kitchen book. This includes:
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.10.0/bin/../ Lib < / Pre> and the library should be in place:
[root @ localhost /] $ ll /opt/chef/embedded/lib/ruby/gems/1.9.1/gems / Chef-11.10.0 / lib / chef / resource / cookbook_file.rb -rw-r - r-- 1 root root 1598 6 February 17:22 /opt/chef/embedded/lib/ruby/gems/1.9.1/ Text after "Gems / Chef-11.10.0 / lib / Chef / Resources / cookbook_file.rb
Before :: Chef :: resource :: cookbook file class MyCookbookFile & lt; :: Chef :: Resources :: CookbookFile and move your my_cookbook_file.rb libraries cookbook folder, Since you use pure ruby and not LWRP syntax.
Comments
Post a Comment