Code Shipping - Provisioning in Vagrant.
config.vm.provision :shell, path: "mydir/myScript.sh"
where:
For complex provisioning scripts, it may be more efficient to package a custom Vagrant box with those packages pre-installed instead of building them each time. See the packaging custom boxes documentation.
Provisioning happens at certain points during the lifetime of your Vagrant environment:
You can also bring up your environment and explicitly not run provisioners by specifying –no-provision.
Vagrant.configure("2") do |config|
config.vm.box = "hashicorp/precise64"
config.vm.provision :shell, path: "installApache.sh"
end
#!/usr/bin/env bash
apt-get update
apt-get install -y apache2
if ! [ -L /var/www ]; then
rm -rf /var/www
ln -fs /vagrant /var/www
fi