-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
How to restart machine during provision #1983
Comments
Hi @majkinetor You can reboot the machine using the shell provisioner and your OS's reboot command. You can read more about the shell provisioner and rebooting here https://www.packer.io/docs/provisioners/shell.html. Does that answer your question? |
We're using OpenSSH & Windows also, and yes the https://github.com/joefitzgerald/packer-windows/blob/master/scripts/win-updates.ps1 trick of doing repeated windows updates & reboots before ever starting OpenSSH works. For reboots after this we make it the last item in the set of scripts in one provisioner, and then put a minute or two of pause_before setting in the next provisioner to make sure Packer waits at the host. Otherwise OpenSSH can keep running & so the next provisioner starts before the target has finished shutting down pre-reboot. Slow & yucky but usually works, hope to try the WinRM provisioners in https://github.com/packer-community/packer-windows-plugins soon. |
Exactly as @tyrken. Slow & yucky and most of all, not good enough. Maybe for your use case that was fine, but in general case you can't always have rebooting script to be the last one. My problem with |
All of the above is the only way to do this, unfortunately. I'd be happy to entertain a better solution, but we haven't found one yet. |
I think about this. May be add bool variable like need_reboot, and when All of the above is the only way to do this, unfortunately. I'd be happy to — |
@vtolstov Yeah I think for backwards compatbility we likely need to inverse that boolean but yeah probably something like that. |
If you ever end up adding an option like that, it would be nice if it accepted a number of reboots to expect rather than just a boolean. e.g.:
That way if you're using an idempotent provisioner, you can just keep running it with the same parameters, and it should pick up where it left off after each reboot. |
@mitchellh What about a packer-native reboot call? You can handle the reboot in packer so that it's abstracted as packer aims to be - and handle waiting for the OS to become available again before proceeding. |
@wayneworkman it would be great if you could add your use-case to #4555 |
I need to restart machine few times after I provision stuff. OS does some lengthy stuff on next boot, for instance Windows after installing updates.
Is it possible to do this ?
I guess I could be able to do this in setup phase, prior to provision, if I delay ssh service installation as the very last thing I can restart the system. However, setup phase has its limitations on Windows (for instance the amount of files you can upload from the host is limited to the floppy size).
The text was updated successfully, but these errors were encountered: