[chef] RE: Can't use powershell_out command


Chronological Thread 
  • From: Kapil Shardha < >
  • To: " " < >
  • Subject: [chef] RE: Can't use powershell_out command
  • Date: Mon, 15 Sep 2014 19:53:57 +0000
  • Accept-language: en-US

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

 

 

From: Avargil, Raanan [mailto:
Sent: Monday, September 15, 2014 3:46 PM
To:
Cc: Avargil, Raanan
Subject: [chef] Can't use powershell_out command

 

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.

 

---------------------------------------------------------------------
Intel Israel (74) Limited

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.




Archive powered by MHonArc 2.6.16.

§