1

My requirement is to restart the windows vm after the software gets installed, I am automating the entire process using chef. Is there any method for doing that?

Can we do through power shell ?
Is there any method for chef to that ?

Robert
  • 10,403
  • 14
  • 67
  • 117

2 Answers2

1

The windows cookbook offers a reboot resource.

StephenKing
  • 36,187
  • 11
  • 83
  • 112
  • when i am using the reboot resource , the VM is actually not getting restarted , and i am getting the following error ERROR: WinRM::WinRMHTTPTransportError: Bad HTTP response returned from server (500) – Mohan Karthik Sanagapalli Jun 06 '14 at 05:57
1

As mentioned above check out the links windows cookbook & windows reboot. All my info is gathered from the previous links.

Include the WindowsRebootHandler in the recipe

include_recipe 'windows::reboot_handler'

Create a reboot block

windows_reboot 30 do
  timeout 30
  reason 'Restarting computer in 30 seconds!'
  action :nothing
end
  • timeout: timeout delay in seconds before rebooting. default is 60 seconds
  • reason: reason for the reboot. default is 'Opscode Chef initiated reboot'

Notify the reboot block to trigger the reboot

notifies :request, 'windows_reboot[30]', :delayed
  • :delayed - notification is queued up and executed at the very end of a chef-client run
  • :immediately - notification is ran immediately
Sanderp
  • 21
  • 1
  • when i am using the reboot resource , the VM is actually not getting restarted , and i am getting the following error ERROR: WinRM::WinRMHTTPTransportError: Bad HTTP response returned from server (500) – Mohan Karthik Sanagapalli Jun 06 '14 at 05:48
  • Seems like WinRM isn't setup properly on the target server but hard to tell without knowing the Chef commands you are using. I have explained Windows Chef bootstrap previously [here](https://stackoverflow.com/questions/23813486/unable-to-bootstrap-chef-on-windows/23919580#23919580). – Sanderp Jun 06 '14 at 18:00