Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/trusty64" # The box NAME to use, will be downloaded
config.vm.network "private_network", ip: "10.0.0.10"
# or config.vm.network :private_network, ip: "192.168.33.10" # create priv network
config.vm.hostname = "icatbeta" # set hostname
end
config.vm.synced_folder "./", "/var/www", create: true, group: "www-data", owner: "www-data"
where the args are
arg | description |
---|---|
./ | Host machine folder (OS X) to be shared with the machine .. Also current dir where Vagrantfile is located |
/var/www | The target machine (linux) folder where it should be moounted |
create: true | specifies that if the target folder (/var/www) does not exist, then create it automatically. |
group: “www-data” and owner: “www-data” | specifies the owner and the group of the shared folder inside the VM. By default most web servers use www-data as the owner accessing the files, it’s a good practice to set the ownership to this user |
Note that Vagrant will provision the virtual machine only once on the first run, any subsequent provisioning must be executed with the
--provision
flag eithervagrant up --provision
orvagrant reload --provision
config.vm.provision "shell", inline: "echo "hello"
config.vm.provision "bootstrap", type: "shell", path: "provision-centos74ICAT.sh"
config.vm.provision "bootstrap", type: "shell" do |s|
s.path = "provision-centos74ICAT.sh"
end
config.vm.provision "shell"do |s|
s.inline="echo "hello"
end
config.vm.provision "bootstrap-system", type: "shell", path: "vm_provision/provision-ubuntu.sh"
config.vm.provision "bootstrap-icat", type: "shell" do |s|
s.path = "vm_provision/bootstrap-icat.sh"
end
will start the 2 provisioning scripts see /Users/sxxx/_Projects/insti/ICAT/Virtualization/ICAT-Beta-ubuntu/vm_provision
$ vagrant init # create Vagrantfile if not present
$ vagrant up
$ vagrant status
$ vagrant destroy
$ vagrant ssh
$ vagrant ssh -- cmd1;cmd2
$ vagrant reload --provision
$ vagrant box list, list my boxes (see Virtualbox) # Vagrantfile
$ vagrant box add <mytitle> <uri> (uri: URL or user/box (hashicorp/trusty64))