balasaheb barde
balasaheb barde

Reputation: 21

No resource or method named powershell for Chef::Recipe

When I run the powershell script on chef -solo on local System ,it give below error message. I have already added powershell in cookbook,

NoMethodError:-------------
No resource or method named `powershell' for `Chef::Recipe "M3"'

Cookbook Trace:
---------------
  C:\chef\cookbooks\Balasahebb\recipes\M3.rb:44:in `from_file'

Relevant File Content:
----------------------
C:\chef\cookbooks\Balasahebb\recipes\M3.rb:

 37:  #Write the output status of the commands to C:\auto\runstatus in the forma
t status:success or status:failed
 38:
 39:  template "c:\\auto\\zib.conf" do
 40:    source "csb_automaticmssql_configuration.erb"
 41:    #variables({:hostname => "#{HOSTNAME}"})
 42:  end
 43:
 44>> powershell "create configuration directory and copy conf" do
 45:    code <<-EOH
 46:  Backloc=(Get-ItemProperty -Path Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Zman
da\ZIB).BackupSetLocation
 47:  mkdir "#{Backloc}\#{BACKUPSET}"
 48:  CP 'c:\\auto\\zib.conf'  "#{Backloc}\\#{BACKUPSET}\\zib.conf"
 49:
 50:    EOH
 51:    action :run
 52:  end
 53:


Running handlers:
[2015-07-15T13:50:01+05:30] ERROR: Running exception handlers
Running handlers complete
[2015-07-15T13:50:01+05:30] ERROR: Exception handlers complete
Chef Client failed. 0 resources updated in 20.512517 seconds
[2015-07-15T13:50:01+05:30] FATAL: Stack trace dumped to C:/chef/cache/chef-stack
trace.out
[2015-07-15T13:50:01+05:30] FATAL: No Method Error: No resource or method named `p
power shell' for `Chef::Recipe "M3"`enter code here`'

Upvotes: 0

Views: 1962

Answers (1)

Martin
Martin

Reputation: 2825

You should add depends 'powershell' to your metadata.rb file, if you want that resource available. This is assuming you are using the powershell community cookbook, and not just looking for the powershell_script resource that comes with Chef.

Upvotes: 1

Related Questions