Assuming
- You are using Vagrant and Shell provisioner often (e.g when doing Windows provisioning you will end up using Powershell a lot)
- You have started running into the problem of reusing your scripts
In this case you want to be able to download and run Powershell scripts.
Thankfully Vagrant has this ability built in.
From the reference:
If you use a remote script as part of your provisioning process, you can pass in its URL as the path argument as well. If you are running a Batch or PowerShell script for Windows, make sure that the external path has the proper extension (
".bat"
or".ps1"
), because Windows uses this to determine what kind of file it is to execute. If you exclude this extension, it likely will not work.
Vagrant.configure("2") do |config|
config.vm.provision "shell", path: "https://example.com/provisioner.sh"
end
If you have many provisioners of the same type (e.g shell
) and want to call just one then name the provisioners as shown:
config.vm.provision "name1", type: "shell", do |s|
end
config.vm.provision "name2", type: "shell", do |s|
end
config.vm.provision "name3", type: "shell", do |s|
end
You can then use vagrant provision --provision-with name1
to provision with just the name1
provisioner.