Another option when using shell provisioning is to use external scripts. This can be a good way to keep your script separate, which means it's easier to manage and helps keep your Vagrantfile tidy.
To use an external script, we can use the following syntax:
config.vm.provision "shell", path: "[FILELOCATION]"
In the preceding example, the "[FILELOCATION]" placeholder could be one of two different options:
- A local script on your machine; an example value would be script.sh
- A remote script hosted externally; an example value would be https://example.com/dev/script.sh
One benefit of using a remote script is that anyone who is using that Vagrantfile to run a specific machine configuration will always get the most up-to-date version. If you are on a team of developers and a change is made to the provisioner script, all of the other developers just need to run the vagrant up --provision command and will then be using the same machine.