sous-chefs / powershell

Development repository for the powershell cookbook
https://supermarket.chef.io/cookbooks/powershell
Apache License 2.0
110 stars 88 forks source link

Is there a way to suppress the reboot handler exception (via attribute?) #93

Closed rayterrill closed 8 years ago

rayterrill commented 8 years ago

Cookbook version

3.3.2

Chef-client version

12.11.18.1

Platform Details

Server 2012R2

Scenario:

Installing WMF5 using the PowerShell cookbook, and rebooting immediately, which throws the exception. Is there a way to disable this (via an attribute, etc)?

Steps to Reproduce:

node.set['powershell']['installation_reboot_mode'] = 'immediate_reboot' include_recipe 'powershell::powershell5'

Expected Result:

Provide or identify a mechanism to suppress exception.

Actual Result:

RuntimeError: ruby_block[end_chef_run](powershell::windows_reboot line 16) had an error: RuntimeError: Requested sudden end to the run... I hope this was justified. c:/chef/cache/cookbooks/powershell/recipes/windows_reboot.rb:18:in block (2 levels) in from_file' C:/opscode/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18-universal-mingw32/lib/chef/provider/ruby_block.rb:35:incall' C:/opscode/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18-universal-mingw32/lib/chef/provider/ruby_block.rb:35:in block in action_run' C:/opscode/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18-universal-mingw32/lib/chef/mixin/why_run.rb:52:inadd_action' C:/opscode/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18-universal-mingw32/lib/chef/provider.rb:176:in converge_by' C:/opscode/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18-universal-mingw32/lib/chef/provider/ruby_block.rb:34:inaction_run' C:/opscode/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18-universal-mingw32/lib/chef/provider.rb:145:in run_action' C:/opscode/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18-universal-mingw32/lib/chef/resource.rb:591:inrun_action' C:/opscode/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18-universal-mingw32/lib/chef/runner.rb:69:in run_action' C:/opscode/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18-universal-mingw32/lib/chef/runner.rb:77:inblock in run_action' C:/opscode/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18-universal-mingw32/lib/chef/runner.rb:75:in each' C:/opscode/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18-universal-mingw32/lib/chef/runner.rb:75:inrun_action' C:/opscode/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18-universal-mingw32/lib/chef/runner.rb:77:in block in run_action' C:/opscode/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18-universal-mingw32/lib/chef/runner.rb:75:ineach' C:/opscode/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18-universal-mingw32/lib/chef/runner.rb:75:in run_action' C:/opscode/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18-universal-mingw32/lib/chef/runner.rb:97:inblock (2 levels) in converge' C:/opscode/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18-universal-mingw32/lib/chef/runner.rb:97:in each' C:/opscode/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18-universal-mingw32/lib/chef/runner.rb:97:inblock in converge' C:/opscode/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18-universal-mingw32/lib/chef/resource_collection/resource_list.rb:94:in block in execute_each_resource' C:/opscode/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18-universal-mingw32/lib/chef/resource_collection/stepable_iterator.rb:116:incall' C:/opscode/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18-universal-mingw32/lib/chef/resource_collection/stepable_iterator.rb:116:in call_iterator_block' C:/opscode/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18-universal-mingw32/lib/chef/resource_collection/stepable_iterator.rb:85:instep' C:/opscode/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18-universal-mingw32/lib/chef/resource_collection/stepable_iterator.rb:104:in iterate' C:/opscode/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18-universal-mingw32/lib/chef/resource_collection/stepable_iterator.rb:55:ineach_with_index' C:/opscode/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18-universal-mingw32/lib/chef/resource_collection/resource_list.rb:92:in execute_each_resource' C:/opscode/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18-universal-mingw32/lib/chef/runner.rb:96:inconverge' C:/opscode/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18-universal-mingw32/lib/chef/client.rb:669:in block in converge' C:/opscode/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18-universal-mingw32/lib/chef/client.rb:664:incatch' C:/opscode/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18-universal-mingw32/lib/chef/client.rb:664:in converge' C:/opscode/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18-universal-mingw32/lib/chef/client.rb:703:inconverge_and_save' C:/opscode/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18-universal-mingw32/lib/chef/client.rb:283:in run' C:/opscode/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18-universal-mingw32/lib/chef/application.rb:268:inrun_with_graceful_exit_option' C:/opscode/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18-universal-mingw32/lib/chef/application.rb:244:in block in run_chef_client' C:/opscode/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18-universal-mingw32/lib/chef/local_mode.rb:44:inwith_server_connectivity' C:/opscode/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18-universal-mingw32/lib/chef/application.rb:227:in run_chef_client' C:/opscode/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18-universal-mingw32/lib/chef/application/client.rb:456:insleep_then_run_chef_client' C:/opscode/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18-universal-mingw32/lib/chef/application/client.rb:443:in block in interval_run_chef_client' C:/opscode/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18-universal-mingw32/lib/chef/application/client.rb:442:inloop' C:/opscode/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18-universal-mingw32/lib/chef/application/client.rb:442:in interval_run_chef_client' C:/opscode/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18-universal-mingw32/lib/chef/application/client.rb:426:inrun_application' C:/opscode/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18-universal-mingw32/lib/chef/application.rb:59:in run' C:/opscode/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18-universal-mingw32/bin/chef-client:26:in<top (required)>' C:/opscode/chef/bin/chef-client:62:in load' C:/opscode/chef/bin/chef-client:62:in

'

smurawski commented 8 years ago

This really needs a re-write (I've got a branch in progress) and move to using the core chef reboot resource.

rlaveycal commented 8 years ago

An observation on this: The immediate reboot isn't working for me (Win2012R2, Chef 12.4.1 and 12.12.15). It seems the reboot_pending? guard condition is preventing the reboot handler being notified.

      notifies :request, 'windows_reboot[powershell]', :immediately if reboot_pending? && node['powershell']['installation_reboot_mode'] != 'no_reboot'

The server does reboot at the end of the run as a pending reboot is detected by the handler.

jimmarch commented 8 years ago

I'm guessing this is the same issue I came to report. Trying to get powershell v5 installed to try out using dsc_resource. The windows cookbook seems to have removed the reboot_handler recipe....

https://github.com/chef-cookbooks/windows/commit/98e1d2d0042e0be306606740b47793ff94bbd45f

smurawski commented 8 years ago

This should be fixed via https://github.com/chef-cookbooks/powershell/commit/864f1c5792a3b264c37cce8f9da70481414a93be and we should get a new release of the cookbook out soon.

smurawski commented 8 years ago

closed via #100