[chef] RE: Can't use powershell_out command


Chronological Thread 
  • From: "Avargil, Raanan" < >
  • To: " " < >, " " < >
  • Subject: [chef] RE: Can't use powershell_out command
  • Date: Tue, 16 Sep 2014 04:53:18 +0000
  • Accept-language: en-US

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:
Sent: Monday, September 15, 2014 22:54
To:
Subject: [chef] RE: Can't use powershell_out command

 

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.

---------------------------------------------------------------------
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.

§