I was reading a tutorial in bash where they said to restart the machine, there was no option to restart a service directly, it was a matter of restarting the machine, and then there were more commands after that that still needed to be run when provisioning.
So is there any way to restart a box amid provisioning and then pick up where you left off after that?
I've never done this, but if I had to I would split the script into two pieces, one before restart that includes the restart command, then another that's post install.
The first one would also create a lock file.
The overall script would run the first script if the lock file didn't exist or run the second one if the file exists. This overall script would be set up for startup.
Vagrant has a reboot option for provisioning, however, the reboot guest capabilities is currently not support for Linux.
You can check my plugin out here, https://github.com/secret104278/vagrant_reboot_linux/tree/master , I've implement the function for Linux to reboot.
As far as I know you can't have a single script/set of commands that would carry on where it left off if it attempts to restart the OS, such as:
In this example the second echo call would not be carried out.
You could split the script/commands up and use a plugin such as vagrant reload.
An example snippet of a Vagrantfile to highlight its possible use:
One trick you can employ is to send restart signal and save rest of the provisioning work as a script to be run on boot:
This was tested to work on debian 9, so you may need to enable services or find another way to get your code bootsrapped to run on the next boot if you're running something else.
Unfortunately you can't simply do: