Installing Vagrant came with a decision for me: use the free VirtualBox integration (which is probably sufficient, but feels a bit disloyal to me!) or pay $80 for the VMware plugin that would allow Vagrant to build machines in Fusion (or Workstation, if that’s your thing). If this were something I planned to use every day, I would definitely pony up for the Fusion plugin, but since I’m only learning, I went the free route.
This installation process couldn’t be simpler. Simply download VirtualBox beforehand, and then download the latest version of Vagrant.
- Download VirtualBox – https://www.virtualbox.org/wiki/Downloads
- Download Vagrant – https://www.vagrantup.com/downloads.html
Both applications are a Next > Next > Finish sort of installation. Just download the installer and run it.
To test initial functionality after the install, we’ll run
vagrant init hashicorp/precise32 and then
vagrant up. That’s literally all it takes to get a fully functional Ubuntu machine running on Vagrant! I can’t get a decent Internet connection where I live, but even with my itty-bitty bandwidth, this process was fast. The time from when I decided I wanted to play with Vagrant to the time I was running an Ubuntu VM (which included downloading VirtualBox, Vagrant, and the Ubuntu box) was about 15 minutes! Also, provisioning this box from scratch if everything was previously downloaded takes about 60 seconds on my machine. And if it was already provisioned and just halted, starting it again takes <10 seconds. Imagine how useful this is for quick testing!
Pasted below is the console output from my first Vagrant box. I spun it up, looked around quick, and then destroyed it.[code] Jamess-MacBook-Pro:~ James$ vagrant init hashicorp/precise32
A `Vagrantfile` has been placed in this directory. You are now
ready to `vagrant up` your first virtual environment! Please read
the comments in the Vagrantfile as well as documentation on
`vagrantup.com` for more information on using Vagrant.
Jamess-MacBook-Pro:~ James$ vagrant up
Bringing machine ‘default’ up with ‘virtualbox’ provider…
==> default: Box ‘hashicorp/precise32’ could not be found. Attempting to find and install…
default: Box Provider: virtualbox
default: Box Version: >= 0
==> default: Loading metadata for box ‘hashicorp/precise32’
default: URL: https://atlas.hashicorp.com/hashicorp/precise32
==> default: Adding box ‘hashicorp/precise32’ (v1.0.0) for provider: virtualbox
default: Downloading: https://atlas.hashicorp.com/hashicorp/boxes/precise32/versions/1.0.0/providers/virtualbox.box
==> default: Successfully added box ‘hashicorp/precise32’ (v1.0.0) for ‘virtualbox’!
==> default: Importing base box ‘hashicorp/precise32’…
==> default: Matching MAC address for NAT networking…
==> default: Checking if box ‘hashicorp/precise32’ is up to date…
==> default: Setting the name of the VM: James_default_1435844641420_45300
==> default: Clearing any previously set network interfaces…
==> default: Preparing network interfaces based on configuration…
default: Adapter 1: nat
==> default: Forwarding ports…
default: 22 => 2222 (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: Vagrant insecure key detected. Vagrant will automatically replace
default: this with a newly generated keypair for better security.
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: Guest Additions Version: 4.2.0
default: VirtualBox Version: 4.3
==> default: Mounting shared folders…
default: /vagrant => /Users/James
Jamess-MacBook-Pro:~ James$ vagrant ssh
Welcome to Ubuntu 12.04 LTS (GNU/Linux 3.2.0-23-generic-pae i686)
* Documentation: https://help.ubuntu.com/
New release ‘14.04.2 LTS’ available.
Run ‘do-release-upgrade’ to upgrade to it.
Welcome to your Vagrant-built virtual machine.
Last login: Fri Sep 14 06:22:31 2012 from 10.0.2.2
vagrant@precise32:~$ uname -a
Linux precise32 3.2.0-23-generic-pae #36-Ubuntu SMP Tue Apr 10 22:19:09 UTC 2012 i686 i686 i386 GNU/Linux
vagrant@precise32:~$ lsb_release –all
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 12.04 LTS
eth0 Link encap:Ethernet HWaddr 08:00:27:12:96:98
inet addr:10.0.2.15 Bcast:10.0.2.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fe12:9698/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:528 errors:0 dropped:0 overruns:0 frame:0
TX packets:343 errors:0 dropped:0 overruns:0 carrier:0
RX bytes:62904 (62.9 KB) TX bytes:46635 (46.6 KB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
vagrant@precise32:~$ ping 22.214.171.124
PING 126.96.36.199 (188.8.131.52) 56(84) bytes of data.
64 bytes from 184.108.40.206: icmp_req=1 ttl=63 time=40.1 ms
64 bytes from 220.127.116.11: icmp_req=2 ttl=63 time=37.1 ms
64 bytes from 18.104.22.168: icmp_req=3 ttl=63 time=45.0 ms
64 bytes from 22.214.171.124: icmp_req=4 ttl=63 time=34.5 ms
64 bytes from 126.96.36.199: icmp_req=5 ttl=63 time=35.1 ms
64 bytes from 188.8.131.52: icmp_req=6 ttl=63 time=36.6 ms
— 184.108.40.206 ping statistics —
6 packets transmitted, 6 received, 0% packet loss, time 5011ms
rtt min/avg/max/mdev = 34.575/38.106/45.024/3.566 ms
Connection to 127.0.0.1 closed.
Jamess-MacBook-Pro:~ James$ vagrant destroy
default: Are you sure you want to destroy the ‘default’ VM? [y/N] Y
==> default: Forcing shutdown of VM…
==> default: Destroying VM and associated drives…