Vagrant
virtualbox and vagrant should be installed first.
Vagrant file example:
Vagrant.configure("2") do |config|
config.vm.define "ubuntu" do |machine|
machine.vm.box = "precise32"
machine.vm.box_url = "http://files.vagrantup.com/precise32.box"
machine.vm.hostname = "example.com"
machine.vm.network :private_network, ip: "192.168.33.10"
machine.vm.synced_folder "src/", "/home/vagrant/src", create: true, mount_options: ["dmode=777","fmode=666"]
machine.vm.provider "virtualbox" do |v|
v.name = "example.com"
v.memory = 256
end
end
end
Vagrant file example for multiple machines:
hosts = {
"ubuntu" => {
"box" => "precise64",
"url" => "http://files.vagrantup.com/precise64.box",
"ip" => "192.168.33.101"
},
"debian" => {
"box" => "debian7",
"url" => "http://puppet-vagrant-boxes.puppetlabs.com/debian-70rc1-x64-vbox4210-nocm.box",
"ip" => "192.168.33.102"
},
"centos" => {
"box" => "centos6",
"url" => "http://puppet-vagrant-boxes.puppetlabs.com/centos-64-x64-vbox4210-nocm.box",
"ip" => "192.168.33.103"
}
}
Vagrant.configure("2") do |config|
hosts.each do |name, options|
config.vm.define name do |machine|
machine.vm.box = options['box']
machine.vm.box_url = options['url']
machine.vm.hostname = "%s" % name
machine.vm.network :private_network, ip: options['ip']
machine.vm.synced_folder "%s/" % name, "/home/vagrant", create: true, mount_options: ["dmode=777","fmode=666"]
machine.vm.provider "virtualbox" do |v|
v.name = name
v.memory = 256
end
end
end
end
On Windows mount_options
can be used for synced_folder
to have something other that 777 for all files.
Basic commands:
vagrant up
- will create and run defined virtual machines vagrant destroy
- will delete them vagrant reload
- reload machines to apply new config options
vagrant halt
, vagrant suspend
and vagrant resume
- can be used for free host machine resources while you do not need you virtual machines.
Usually passwords for root and vagrant users are vagrant