Hi Kapil, Thank for youe answer! It didn’t work for me. The source of the error moved to the library instead of the recipe. See below: Compiling Cookbooks... ================================================================================ Recipe Compile Error in c:/chef/cache/cookbooks/lan_driver/libraries/default.rb ================================================================================ NameError --------- uninitialized constant Chef::Mixin::PowershellOut Cookbook Trace: --------------- c:/chef/cache/cookbooks/lan_driver/libraries/default.rb:3:in `<class:Resource>' c:/chef/cache/cookbooks/lan_driver/libraries/default.rb:2:in `<class:Chef>' c:/chef/cache/cookbooks/lan_driver/libraries/default.rb:1:in `<top (required)>' Relevant File Content: ---------------------- c:/chef/cache/cookbooks/lan_driver/libraries/default.rb: 1: class Chef 2: class Resource 3>> include Chef::Mixin::PowershellOut 4: end 5: end 6: Running handlers: [2014-09-16T07:44:12+03:00] ERROR: Running exception handlers Running handlers complete [2014-09-16T07:44:12+03:00] ERROR: Exception handlers complete [2014-09-16T07:44:12+03:00] FATAL: Stacktrace dumped to c:/chef/cache/chef-stacktrace.out Chef Client failed. 0 resources updated in 9.402607 seconds [2014-09-16T07:44:12+03:00] FATAL: NameError: uninitialized constant Chef::Mixin::PowershellOut I feel like I miss something very basic. Raanan From: Kapil Shardha [mailto:
Few months ago I ran into same issue and I was suggested on this forum to have a “library” file with following content: class Chef class Resource include Chef::Mixin::PowershellOut end end This helped me. Try that and see if it works for you. Thanks -Kapil Hello all, I’m trying to use the powershell_out command, but get an error while including the Chef::Mixin::PowerShellOut. This is my recipe: Chef::Resource.send(:include, Chef::Mixin::WindowsArchitectureHelper) Chef::Resource.send(:include, Chef::Mixin::PowershellOut) cmd = powershell_out!('write-host Hello World'); Chef::Log::info("cmd.stdout = #{cmd.stdout}") Chef::Log::info("cmd.stderr = #{cmd.stderr}") And this is the error I get: ================================================================================ Recipe Compile Error in c:/chef/cache/cookbooks/lan_driver/recipes/default.rb ================================================================================ NameError --------- uninitialized constant Chef::Mixin::PowershellOut Cookbook Trace: --------------- c:/chef/cache/cookbooks/lan_driver/recipes/default.rb:13:in `from_file' Relevant File Content: ---------------------- c:/chef/cache/cookbooks/lan_driver/recipes/default.rb: 6: # 7: # All rights reserved - Do Not Redistribute 8: # 9: 10: 11: 12: Chef::Resource.send(:include, Chef::Mixin::WindowsArchitectureHelper) 13>> Chef::Resource.send(:include, Chef::Mixin::PowershellOut) 14: 15: 16: cmd = powershell_out!('write-host Hello World'); 17: Chef::Log::info("cmd.stdout = #{cmd.stdout}") 18: Chef::Log::info("cmd.stderr = #{cmd.stderr}") 19: 20: 21: 22: Running handlers: [2014-09-15T22:35:51+03:00] ERROR: Running exception handlers Running handlers complete [2014-09-15T22:35:51+03:00] ERROR: Exception handlers complete [2014-09-15T22:35:51+03:00] FATAL: Stacktrace dumped to c:/chef/cache/chef-stacktrace.out Chef Client failed. 0 resources updated in 8.967519 seconds [2014-09-15T22:35:51+03:00] FATAL: NameError: uninitialized constant Chef::Mixin::PowershellOut Please note that there is no error at the first line (Chef::Resource.send(:include, Chef::Mixin::WindowsArchitectureHelper)),
only at the second line. I added the first line just for debugging. I use Chef version 11.12.8. What do I miss here? Thanks, Raanan. --------------------------------------------------------------------- This e-mail and any attachments may contain confidential material for --------------------------------------------------------------------- This e-mail and any attachments may contain confidential material for |
Archive powered by MHonArc 2.6.16.