⬅️ **[[$-Tools|Tools]]** *** # Vagrant **Links:** - [Vagrant VM Cluster - Network](http://jessesnet.com/development-notes/2014/vagrant-virtual-machine-cluster/) ## Setup - Install VirtualBox - Install Vagrant - Have both in environment variable Path - check with `vboxmanage --version` - check with `vagrant --version` ## Setup a VM - `vagrant box add bento/centos-7.2 --provider=virtualbox` creates `Vagrantfile` containing VM Configuration - Edit `Vagrantfile`: ```bash Vagrant.configure("2") do |config| config.vm.provision "shell", inline: "echo Hello" # VM config.vm.define "chef" do |chef| chef.vm.box = "bento/centos-7.2" chef.vm.network "private_network", ip: "192.168.56.10", virtualbox__intnet: true end config.vm.define "web1" do |web1| web1.vm.box = "bento/centos-7.2" web1.vm.network "private_network", ip: "192.168.56.11", virtualbox__intnet: true end config.vm.define "web2" do |web2| web2.vm.box = "bento/centos-7.2" web2.vm.network "private_network", ip: "192.168.56.12", virtualbox__intnet: true end config.vm.define "loadbalancer" do |loadbalancer| loadbalancer.vm.box = "bento/centos-7.2" loadbalancer.vm.network "private_network", ip: "192.168.56.15", virtualbox__intnet: true end config.proxy.http = "http://proxy.bbn.hp.com:8080" config.proxy.https = "http://proxy.bbn.hp.com:8080" config.proxy.no_proxy = "localhost,127.0.0.1" end ``` - `vagrant up` ``` $ vagrant.exe up Bringing machine 'default' up with 'virtualbox' provider... ==> default: Checking if box 'bento/centos-7.2' is up to date... ==> default: There was a problem while downloading the metadata for your box ==> default: to check for updates. This is not an error, since it is usually due ==> default: to temporary network problems. This is just a warning. The problem ==> default: encountered was: ==> default: ==> default: Failed to connect to vagrantcloud.com port 443: Timed out ==> default: ==> default: If you want to check for box updates, verify your network connection ==> default: is valid and try again. ==> default: Clearing any previously set forwarded ports... ==> default: Clearing any previously set network interfaces... ==> default: Preparing network interfaces based on configuration... default: Adapter 1: nat ==> default: Forwarding ports... default: 22 (guest) => 2222 (host) (adapter 1) ==> default: Booting VM... ==> default: Waiting for machine to boot. This may take a few minutes... default: SSH address: 127.0.0.1:2222 default: SSH username: vagrant default: SSH auth method: private key default: Warning: Connection reset. Retrying... default: Warning: Connection aborted. Retrying... default: default: Vagrant insecure key detected. Vagrant will automatically replace default: this with a newly generated keypair for better security. default: default: Inserting generated public key within guest... default: Removing insecure key from the guest if its present... default: Key inserted! Disconnecting and reconnecting using new SSH key... ==> default: Machine booted and ready! ==> default: Checking for guest additions in VM... default: The guest additions on this VM do not match the installed version of default: VirtualBox! In most cases this is fine, but in rare cases it can default: prevent things such as shared folders from working properly. If you see default: shared folder errors, please make sure the guest additions within the default: virtual machine match the version of VirtualBox you have installed on default: your host and reload your VM. default: default: Guest Additions Version: 5.1.10 default: VirtualBox Version: 5.2 ==> default: Mounting shared folders... default: /vagrant => C:/cygwin64/home/mauritz/vagrant ==> default: Machine already provisioned. Run "vagrant provision" or use the "--provision" ==> default: flag to force provisioning. Provisioners marked to run always will still run. ``` - Show Vagrant status with `vagrant status` - Log in with SSH using Vagrant `vagrant ssh default` # *** Related: - [[$-Automatisierung]]