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

Powershell reboot fixes #37

Closed tjnicholas closed 9 years ago

tjnicholas commented 9 years ago

I've switched around some of the logic here and added in a ruby_block to explicitly raise an exception - which is needed for the reboot_handler to actually reboot the node prior to the usual end of the run.

Previously the powershellX recipes were only including the windows_reboot recipe for immediate reboots but it is also needed for delayed reboots.

I also added the /norestart and /quiet flags back. Both are needed to reboot 'gracefully' in a way visible to chef.

Added an extra return code which seems to be thrown when a reboot is required (3010).

In windows_reboot added ruby_block to raise an exception if an immediate reboot is required. It does nothing otherwise.

Unless no_reboot is set, the reboot will still happen at the end of the chef run with no exception.

I think this PR can replace #36 from @zl4bv but probably also #32 from @NimishaS.

These changes have been tested with Windows 2008r2 Standard.

zl4bv commented 9 years ago

This PR can definitely replace the one I sent (#36). Will close mine if/when this one gets merged.

NimishaS commented 9 years ago

One more thing we should consider is that, we need reboot in case of chef-client run failure also. Reason behind this is dsc recipe requires powershell 4 to be installed and hence uses powershell4 recipe. So when we are running dsc recipe on a machine which doesn't have powershell 4 installed, the recipe installs powershell 4 first and then the rest of dsc recipe fails because powershell4 needs reboot.

tjnicholas commented 9 years ago

I'm not sure I understand what the DSC recipe is supposed to do. It looks like the only logic in it should be moved to winrm.rb.

From what I can tell it installs powershell 4 but then just checks a command before maybe including the winrm recipe. powershell::dsc doesn't seem to do anything of its own.

I don't know much about Desired State Configuration but I don't think that recipe is doing anything with it or to it.

That said, if you've got 'reboot_immediately' then it should reboot straight after installing powershell4 (with an ugly exception). It will then do the rest of the powershell::dsc recipe when/if chef runs again after the reboot.

adamedx commented 9 years ago

@tjnicholas, thank you for the contribution. I'm not able to find a contributor license agreement for you for this repository -- we require this in order to merge this pull request. Can you sign the agreement? There is more detail on the Chef blog.

Thank you -- if you've signed already and we're just missing it, just let us know and we'll do some more digging to find the agreement.

tjnicholas commented 9 years ago

Thanks @adamedx I hadn't signed it but I have now.

NimishaS commented 9 years ago

@tjnicholas , I have merged your changes into master branch with PR https://github.com/opscode-cookbooks/powershell/pull/38 Thanks for your contribution!