Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NoMethodErrors using Windows and Powershell cookbooks #155

Closed
christrotter opened this issue Dec 12, 2014 · 10 comments
Closed

NoMethodErrors using Windows and Powershell cookbooks #155

christrotter opened this issue Dec 12, 2014 · 10 comments

Comments

@christrotter
Copy link

I updated our chef-server to v12.0.0 today (chasing SSL issues), now a chef-client run returns this:

Windows PowerShell
Copyright (C) 2013 Microsoft Corporation. All rights reserved.

PS C:\Windows\system32> chef-client
Starting Chef Client, version 12.0.1
[2014-12-12T13:33:02-05:00] INFO: *** Chef 12.0.1 ***
[2014-12-12T13:33:02-05:00] INFO: Chef-client pid: 5012
[2014-12-12T13:33:10-05:00] INFO: Run List is [recipe[windows], role[CORP-baseWindows]]
[2014-12-12T13:33:10-05:00] INFO: Run List expands to [windows, CORP-Roles::CORP-baseWindows]
[2014-12-12T13:33:10-05:00] INFO: Starting Chef Run for servername
[2014-12-12T13:33:10-05:00] INFO: Running start handlers
[2014-12-12T13:33:10-05:00] INFO: Start handlers complete.
[2014-12-12T13:33:10-05:00] INFO: HTTP Request Returned 404 Not Found:
resolving cookbooks for run list: ["windows", "CORP-Roles::CORP-baseWindows"]
[2014-12-12T13:33:10-05:00] INFO: Loading cookbooks [windows@1.34.8, chef_handler@1.1.6, CORP-Roles@0.1.0, CORP-baseWindows@0.1.0, CORP-WindowsWebLayer@0.1.0, iis@2.1.6, CORP-WELT@0.1.0, ResponseDriver.WebUI@0.1.0, NXlog@0.1.0, CheckMKagent@0.1
.0, CORP-graphite_powershell_functions@1.1.0, powershell@3.0.7, ms_dotnet45@2.0.0, ms_dotnet4@1.0.2, ms_dotnet2@1.0.0, ms_dotnet35@1.0.1]
Synchronizing Cookbooks:
  - windows
  - chef_handler
  - CORP-Roles
  - CORP-baseWindows
  - CORP-WindowsWebLayer
  - iis
  - CORP-WELT
  - ResponseDriver.WebUI
  - CORP-graphite_powershell_functions
  - CheckMKagent
  - powershell
  - ms_dotnet45
  - ms_dotnet4
  - ms_dotnet2
  - ms_dotnet35
  - NXlog
Compiling Cookbooks...
[2014-12-12T13:33:11-05:00] INFO: WindowsPackage light-weight resource is already initialized -- Skipping loading c:/chef/cache/cookbooks/windows/resources/package.rb!
[2014-12-12T13:33:11-05:00] INFO: Powershell light-weight provider is already initialized -- Skipping loading c:/chef/cache/cookbooks/powershell/providers/default.rb!
Recipe: windows::default
  * chef_gem[win32-api] action install[2014-12-12T13:33:11-05:00] INFO: Processing chef_gem[win32-api] action install (windows::default line 23)
 (up to date)
  * chef_gem[win32-service] action install[2014-12-12T13:33:11-05:00] INFO: Processing chef_gem[win32-service] action install (windows::default line 23)
 (up to date)
  * chef_gem[windows-api] action install[2014-12-12T13:33:11-05:00] INFO: Processing chef_gem[windows-api] action install (windows::default line 31)
 (up to date)
  * chef_gem[windows-pr] action install[2014-12-12T13:33:11-05:00] INFO: Processing chef_gem[windows-pr] action install
(windows::default line 31)
 (up to date)
  * chef_gem[win32-dir] action install[2014-12-12T13:33:11-05:00] INFO: Processing chef_gem[win32-dir] action install (windows::default line 31)
 (up to date)
  * chef_gem[win32-event] action install[2014-12-12T13:33:11-05:00] INFO: Processing chef_gem[win32-event] action install (windows::default line 31)
 (up to date)
  * chef_gem[win32-mutex] action install[2014-12-12T13:33:11-05:00] INFO: Processing chef_gem[win32-mutex] action install (windows::default line 31)
 (up to date)
[2014-12-12T13:33:11-05:00] WARN: PowerShell 4.0 is not supported or already installed on this version of Windows: 6.3.9600
  Converging 31 resources
  * chef_gem[win32-api] action install[2014-12-12T13:33:11-05:00] INFO: Processing chef_gem[win32-api] action install (windows::default line 23)
 (up to date)
  * chef_gem[win32-service] action install[2014-12-12T13:33:11-05:00] INFO: Processing chef_gem[win32-service] action install (windows::default line 23)
 (up to date)
  * chef_gem[windows-api] action install[2014-12-12T13:33:11-05:00] INFO: Processing chef_gem[windows-api] action install (windows::default line 31)
 (up to date)
  * chef_gem[windows-pr] action install[2014-12-12T13:33:11-05:00] INFO: Processing chef_gem[windows-pr] action install
(windows::default line 31)
 (up to date)
  * chef_gem[win32-dir] action install[2014-12-12T13:33:12-05:00] INFO: Processing chef_gem[win32-dir] action install (windows::default line 31)
 (up to date)
  * chef_gem[win32-event] action install[2014-12-12T13:33:12-05:00] INFO: Processing chef_gem[win32-event] action install (windows::default line 31)
 (up to date)
  * chef_gem[win32-mutex] action install[2014-12-12T13:33:12-05:00] INFO: Processing chef_gem[win32-mutex] action install (windows::default line 31)
 (up to date)
Recipe: CORP-baseWindows::default
  * windows_feature[TelnetClient] action install[2014-12-12T13:33:12-05:00] INFO: Processing windows_feature[TelnetClient] action install (CORP-baseWindows::default line 12)
 (up to date)
  * directory[C:\temp] action create[2014-12-12T13:33:14-05:00] INFO: Processing directory[C:\temp] action create (CORP-baseWindows::default line 18)
 (up to date)
  * directory[C:\coldStorage] action create[2014-12-12T13:33:15-05:00] INFO: Processing directory[C:\coldStorage] action
 create (CORP-baseWindows::default line 27)
 (up to date)
Recipe: NXlog::default
  * cookbook_file[nxlog-ce-2.8.1248.msi] action create[2014-12-12T13:33:15-05:00] INFO: Processing cookbook_file[nxlog-ce-2.8.1248.msi] action create (NXlog::default line 14)
 (up to date)
  * windows_package[NXlog] action install[2014-12-12T13:33:15-05:00] INFO: Processing windows_package[NXlog] action install (NXlog::default line 20)


    ================================================================================
    Error executing action `install` on resource 'windows_package[NXlog]'
    ================================================================================

    NoMethodError
    -------------
    undefined method `shell_out!' for #<Chef::Provider::Package::Windows::MSI:0x1d14b90>

    Resource Declaration:
    ---------------------
    # In c:/chef/cache/cookbooks/NXlog/recipes/default.rb

     20: windows_package "NXlog" do
     21:        package_name "NXlog-client"
     22:        source 'C:\temp\nxlog-ce-2.8.1248.msi'
     23:        installer_type :msi
     24:        action :install
     25:        not_if 'C:\\windows\\system32\\WindowsPowerShell\\v1.0\\powershell.exe -NoLogo -NonInteractive -NoProfile -ExecutionPolicy RemoteSigned Get-Service -Name NXlog'
     26: end
     27:

    Compiled Resource:
    ------------------
    # Declared in c:/chef/cache/cookbooks/NXlog/recipes/default.rb:20:in `from_file'

    windows_package("NXlog") do
      action [:install]
      retries 0
      retry_delay 2
      default_guard_interpreter :default
      package_name "NXlog-client"
      source "C:\\temp\\nxlog-ce-2.8.1248.msi"
      version "2.8.1248\x00"
      timeout 600
      installer_type :msi
      returns [0]
      cookbook_name "NXlog"
      recipe_name "default"
      not_if "C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe -NoLogo -NonInteractive -NoProfile -ExecutionPolicy RemoteSigned Get-Service -Name NXlog"
    end

[2014-12-12T13:33:17-05:00] INFO: Running queued delayed notifications before re-raising exception

Running handlers:
[2014-12-12T13:33:17-05:00] ERROR: Running exception handlers
Running handlers complete
[2014-12-12T13:33:17-05:00] ERROR: Exception handlers complete
[2014-12-12T13:33:17-05:00] FATAL: Stacktrace dumped to c:/chef/cache/chef-stacktrace.out
Chef Client failed. 0 resources updated in 24.469287 seconds
[2014-12-12T13:33:17-05:00] FATAL: NoMethodError: windows_package[NXlog] (NXlog::default line 20) had an error: NoMethod
Error: undefined method `shell_out!' for #<Chef::Provider::Package::Windows::MSI:0x1d14b90>

On hosts that need powershell v4 installed (the above is 2012R2), like 2008R2, I was also seeing the same error style but for 'checksum'. Commenting out the 'checksum' line in the powershell v4 recipe allowed the install to complete.

This link describes my issue pretty close: http://lists.opscode.com/sympa/arc/chef/2014-07/msg00226.html

Debug info looks like this:

servername [2014-12-12T13:22:01-05:00] DEBUG: Server doesn't support resource history, skipping resource report.
servername [2014-12-12T13:22:01-05:00] FATAL: NoMethodError: windows_package[NXlog] (NXlog::default line 20) had an erro
r: NoMethodError: undefined method `shell_out!' for #<Chef::Provider::Package::Windows::MSI:0x103eae0>
ERROR: Failed to execute command on servername return code 1

Line#20 of the referenced recipe:

# Install NXlog
windows_package "NXlog" do
    package_name "NXlog-client"
    source 'C:\temp\nxlog-ce-2.8.1248.msi' 
    installer_type :msi
    action :install
    not_if 'C:\\windows\\system32\\WindowsPowerShell\\v1.0\\powershell.exe -NoLogo -NonInteractive -NoProfile -ExecutionPolicy RemoteSigned Get-Service -Name NXlog'  
end

At this point, unless this is an easy fix, I have no choice but to downgrade. Pretty sure this is an issue with the windows cookbook, but still a Chef newbie....so...maybe I've broken something?

@jaym
Copy link
Contributor

jaym commented Dec 12, 2014

chef/chef#2625

@jaym
Copy link
Contributor

jaym commented Dec 12, 2014

Also, if this is using the windows cookbook, you are being affected by the same issue that causes #150

@christrotter
Copy link
Author

Glad to know it's not just me. If any further info/debug is required, I'm happy to help!

@jaym
Copy link
Contributor

jaym commented Dec 12, 2014

I think we should be good, should have a release both to Chef and the windows cookbook with both issues fixed on Monday

@christrotter
Copy link
Author

Awesome - thanks a ton!

@lonniev
Copy link

lonniev commented Dec 12, 2014

What's the last known good version of the opscode windows cookbook so that users can fallback to something workable over the hectic weekend?

Perhaps just before the last PR at 1298ae5 ?

@lonniev
Copy link

lonniev commented Dec 14, 2014

As @jdmundrawala reports, the master commit here resolves this NoMethodError for shell_out! and for checksum. My Vagrant+chef for a Windows guest is now past this issue. Thanks for the fix, guys.

Now, does anyone on this Windows team know why chef-solo on the Windows VM would be unable to find the rb roles files that are in the roles directory, that is properly mounted for the VM, that is just as readable as the cookbooks and environments directories, and which contains *.rb files that match the names of those files and have a name DSL attribute which also matches? That is, everything looks legit for the roles (and the Vagrantfile and chef setup work as-is for Ubuntu guests) but nevertheless chef-solo complains that the roles requested through chef.add_role "foo" are missing.

@christrotter
Copy link
Author

Hm...I cloned the master branch of the Opscode Windows cookbook from github, deleted the old from my Chef server, uploaded the new one...but still having issues. Maybe it's simple...? I fully nuked chef-client off this VM, uninstalled, cleaned the dirs, etc...

Edit: I should note - this is on a 2008R2 box. The 2012R2 box is working again.
Edit2: Of course, 2012R2 doesn't need powershell installed... The 2012 box is also failing...adding that below... I'll keep troubleshooting and report back.

<SNIP>
Compiling Cookbooks...
[2014-12-15T08:03:40-05:00] INFO: Powershell light-weight provider is already initialized -- Skipping loading c:/chef/cache/cookbooks/powershell/providers/default.rb!
Converging 25 resources
Recipe: CORP-baseWindows::default
  * windows_feature[TelnetClient] action install[2014-12-15T08:03:41-05:00] INFO: Processing windows_feature[TelnetClient] action install (CORP-baseWindows::default line 12)
C:/opscode/chef/embedded/lib/ruby/gems/2.0.0/gems/mixlib-shellout-2.0.0-x86-mingw32/lib/mixlib/shellout/windows.rb:152:
[BUG] Segmentation fault
ruby 2.0.0p451 (2014-02-24) [i386-mingw32]

-- Control frame information -----------------------------------------------
c:0040 p:---- s:0177 e:000176 CFUNC  :select
c:0039 p:0042 s:0170 e:000169 METHOD C:/opscode/chef/embedded/lib/ruby/gems/2.0.0/gems/mixlib-shellout-2.0.0-x86-mingw32
/lib/mixlib/shellout/windows.rb:152
c:0038 p:0532 s:0162 e:000161 METHOD C:/opscode/chef/embedded/lib/ruby/gems/2.0.0/gems/mixlib-shellout-2.0.0-x86-mingw32
/lib/mixlib/shellout/windows.rb:117
c:0037 p:0065 s:0145 e:000144 METHOD C:/opscode/chef/embedded/lib/ruby/gems/2.0.0/gems/mixlib-shellout-2.0.0-x86-mingw32
/lib/mixlib/shellout.rb:237
c:0036 p:0052 s:0141 e:000140 METHOD C:/opscode/chef/embedded/apps/chef/lib/chef/mixin/shell_out.rb:91
<SNIP>
serverName [2014-12-15T08:29:53-05:00] INFO: Processing windows_package[Windows Management Framework Core4.0] action install (powershell::powershell4 line 36)
serverName [2014-12-15T08:29:54-05:00] INFO: Installing windows_package[Windows Management Framework Core4.0] version latest
serverName [2014-12-15T08:29:54-05:00] INFO: Processing remote_file[c:/chef/cache/Windows8-RT-KB2799888-x64.msu] action create (dynamically defined)
serverName [2014-12-15T08:29:56-05:00] INFO: remote_file[c:/chef/cache/Windows8-RT-KB2799888-x64.msu] created file c:/chef/cache/Windows8-RT-KB2799888-x64.msu
serverName [2014-12-15T08:29:56-05:00] INFO: remote_file[c:/chef/cache/Windows8-RT-KB2799888-x64.msu] updated file contents c:/chef/cache/Windows8-RT-KB2799888-x64.msu
serverName [2014-12-15T08:29:57-05:00] INFO: Starting installation...this could take awhile.
serverName
serverName ================================================================================
serverName Error executing action `install` on resource 'windows_package[Windows Management Framework Core4.0]'
serverName ================================================================================
serverName
serverName Mixlib::ShellOut::ShellCommandFailed
serverName ------------------------------------
serverName Expected process to exit with [0, 42, 127], but received '5'
serverName ---- Begin output of start "" /wait "c:\chef\cache\Windows8-RT-KB2799888-x64.msu" /quiet /restart & exit %%ERRORLEVEL%% ----
serverName STDOUT:
serverName STDERR:
serverName ---- End output of start "" /wait "c:\chef\cache\Windows8-RT-KB2799888-x64.msu" /quiet /restart & exit %%ERRORLEVEL%% ----
serverName Ran start "" /wait "c:\chef\cache\Windows8-RT-KB2799888-x64.msu" /quiet /restart & exit %%ERRORLEVEL%% returned 5
serverName
serverName Cookbook Trace:
serverName ---------------
serverName c:/chef/cache/cookbooks/windows/libraries/windows_package.rb:109:in `install_package'
serverName c:/chef/cache/cookbooks/windows/libraries/windows_package.rb:31:in `block in <class:WindowsCookbookPackage>'
serverName
serverName Resource Declaration:
serverName ---------------------
serverName # In c:/chef/cache/cookbooks/powershell/recipes/powershell4.rb
serverName
serverName  36:     windows_package 'Windows Management Framework Core4.0' do
serverName  37:       source node['powershell']['powershell4']['url']
serverName  38:       #checksum node['powershell']['powershell4']['checksum']
serverName  39:       installer_type :custom
serverName  40:       action :install
serverName  41:           options '/quiet /restart'
serverName  42:       not_if do
serverName  43:         begin
serverName  44:           registry_data_exists?('HKLM\SOFTWARE\Microsoft\PowerShell\3\PowerShellEngine', { :name => 'PowerShellVersion', :type => :string, :data => '4.0' })
serverName  45:         rescue Chef::Exceptions::Win32RegKeyMissing
serverName  46:           false
serverName  47:         end
serverName  48:       end
serverName  49:     end
serverName
serverName Compiled Resource:
serverName ------------------
serverName # Declared in c:/chef/cache/cookbooks/powershell/recipes/powershell4.rb:36:in `from_file'
serverName
serverName windows_cookbook_package("Windows Management Framework Core4.0") do
serverName   provider Chef::Provider::WindowsCookbookPackage
serverName   action [:install]
serverName   retries 0
serverName   retry_delay 2
serverName   default_guard_interpreter :default
serverName   cookbook_name "powershell"
serverName   recipe_name "powershell4"
serverName   source "http://download.microsoft.com/download/3/D/6/3D61D262-8549-4769-A660-230B67E15B25/Windows8-RT-KB2799888-x64.msu"
serverName   installer_type :custom
serverName   options "/quiet /restart"
serverName   package_name "Windows Management Framework Core4.0"
serverName   timeout 600
serverName   success_codes [0, 42, 127]
serverName   not_if { #code block }
serverName end
serverName
serverName [2014-12-15T08:29:58-05:00] INFO: Running queued delayed notifications before re-raising exception
serverName [2014-12-15T08:29:58-05:00] ERROR: Running exception handlers
serverName [2014-12-15T08:29:58-05:00] ERROR: Exception handlers complete
serverName [2014-12-15T08:29:58-05:00] FATAL: Stacktrace dumped to c:/chef/cache/chef-stacktrace.out
serverName [2014-12-15T08:29:58-05:00] FATAL: Mixlib::ShellOut::ShellCommandFailed: windows_package[Windows Management Framework Core4.0] (powershell::powershell4 line 36) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process
 to exit with [0, 42, 127], but received '5'
serverName ---- Begin output of start "" /wait "c:\chef\cache\Windows8-RT-KB2799888-x64.msu" /quiet /restart & exit %%ERRORLEVEL%% ----
serverName STDOUT:
serverName STDERR:
serverName ---- End output of start "" /wait "c:\chef\cache\Windows8-RT-KB2799888-x64.msu" /quiet /restart & exit %%ERRORLEVEL%% ----
serverName Ran start "" /wait "c:\chef\cache\Windows8-RT-KB2799888-x64.msu" /quiet /restart & exit %%ERRORLEVEL%% returned 5

@christrotter
Copy link
Author

I'm assuming this is fixed with the patch to Chef 12.0.0 - I couldn't find any info on when the new RPM would come out, and didn't see anything particular on updating an RPM install w. github code. (assuming it's a bad idea)

Could someone please point me in the right direction? (or let me know when new packages will be ready?) Thanks!

@christrotter
Copy link
Author

Thought I'd update and close this. I saw that 12.0.1 was released, so updated to that - no luck, did not resolve the issue I was having. Closer inspection revealed it seemed to be an issue with chef-client 12.x running on 2008 R2 (was getting Ruby segmentation faults). I now run with --bootstrap-version=11.16.4-01 (or whatever it is) and having no issues doing chef runs on those clients.

So there ya go.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants