Vagrant Plugin Recommendations

Today a few Vagrant Plugin Recommendations.

Preconditions

Preparation

Create a simple Vagrant BaseBox (as here) and if you like use the following Vagrantfile.

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure(2) do |config|
  config.vm.box = "lupin/centos7"
  # config.vm.network "public_network"
  config.vm.synced_folder ".", "/vagrant", disabled: true
  # config.vm.synced_folder "./shared", "/vagrant"

  config.vm.provider "virtualbox" do |vb|
    vb.cpus = "2"
    vb.memory = "2048"
  end

  if Vagrant.has_plugin?("vagrant-hostsupdater")
    config.vm.network :private_network, ip: "10.0.0.10"
    config.hostsupdater.aliases = ["example.test"]
  end

  config.vm.provision "shell", inline: <<-SHELL
    sudo yum update -y
    sudo yum install -y vim docker
    sudo yum clean all
    sudo systemctl enable docker
    sudo systemctl start docker
    sudo setenforce 0
  SHELL

  config.vm.provision "docker" do |d|
    d.run "nginx", args: "-p 8080:80"
  end

  config.vm.provision "shell", inline: "sudo hostname -I"
end

1. vagrant-camera

# install camera plugin
$ vagrant plugin install vagrant-camera

# start VM via Vagrant
$ vagrant up

# do screenshot on current target folder
$ vagrant camera -s .

# show all pictures (Mac OS X)
$ open screenshot_default_*.png

2. vagrant-vbguest

# start VM via Vagrant
$ vagrant up

# ssh into VM (optional)
$ vagrant ssh

# check current version (optional)
$ VBoxControl --version
...
5.0.20r106931

# exit from VM (optional)
$ exit

# install vbguest plugin
$ vagrant plugin install vagrant-vbguest

# reload VM
$ vagrant reload

# ssh into VM (optional)
$ vagrant ssh

# list all downloaded (optional)
$ ls -l /opt
...
VBoxGuestAdditions-5.0.14
VBoxGuestAdditions-5.0.20

3. vagrant-hostsupdater

# install hostsupdater plugin
$ vagrant plugin install vagrant-hostsupdater

# check content of local hosts (optional)
$ cd /etc && cat hosts

# start VM
$ vagrant up

# or reload if already running
$ vagrant reload --provision

# check content of local hosts (optional)
$ cd /etc && cat hosts

# check status
$ vagrant ssh -c 'curl -v example.test:8080'

# stop VM
$ vagrant halt

# check content of local hosts (optional)
$ cd /etc && cat hosts