Plugins

vagrant plugin install ...

  • vagrant-vbguest

      # set auto_update to false, if you do NOT want to check the correct 
    # additions version when booting this machine
    config.vbguest.auto_update = false
    
    # do NOT download the iso file from a webserver
    config.vbguest.no_remote = true
    
  • vagrant-hostmanager

    if Vagrant.has_plugin?("vagrant-hostmanager")
      config.hostmanager.enabled = true
      config.hostmanager.manage_host = true
      config.hostmanager.manage_guest = true
      config.hostmanager.ignore_private_ip = false
      config.hostmanager.include_offline = true
    end
    
  • vagrant-proxyconf

    if Vagrant.has_plugin?("vagrant-proxyconf")
      config.proxy.http     = "http://192.168.0.2:3128/"
      config.proxy.https    = "http://192.168.0.2:3128/"
      config.proxy.no_proxy = "localhost,127.0.0.1,.example.com"
    end
    

Examples

Install Docker and Python 3.6 over CentOS 7 to run Ansible tests via Molecule

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

$provisionning = <<-PROVISIONNING

# A bit of confort
sudo yum install -y curl vim git nmap tee

# Couldn't find python selinux binding for 3.6
sudo setenforce 0
sudo sed -i 's;SELINUX=enforcing;SELINUX=disabled;' /etc/selinux/config

# Docker
sudo curl -fsSL get.docker.com | bash
sudo systemctl start docker
sudo systemctl enable docker
sudo usermod -a -G docker vagrant

# Need python >= 3.5. And gcc is required by some packages installed by pip
sudo yum -y install epel-release
sudo yum -y install https://dl.iuscommunity.org/pub/ius/stable/CentOS/7/x86_64/ius-release-1.0-15.ius.centos7.noarch.rpm
sudo yum -y install python36u python36u-pip python36u-devel git curl gcc
sudo pip3.6 install --upgrade pip ansible molecule docker

# Local CA certificate in rootCA
sudo tee /etc/pki/ca-trust/source/anchors/astellia.der <<B64DER
-----BEGIN CERTIFICATE-----
MIIDrzCCApegAwIBAgIQctBLdKkxF5RJpOn2dgJ3YTANBgkqhkiG9w0BAQ0FADBL
Mblablabla bla bla bla blablaLki+qFfzhrDdxk0lYgKlnx
3SXnWNtoLThAx9OnMu1VyM74=
-----END CERTIFICATE-----
B64DER
sudo update-ca-trust extract

echo
echo "All set. Now just do"
echo
echo "    vagrant reload"
echo "    vagrant ssh"
echo "    cd /vagrant/ansible-role-YOUR_ROLE_NAME"
echo "    molecule test"
echo
echo " "

PROVISIONNING

Vagrant.configure(2) do |config|
  config.vm.box = "centos/7"
  config.vm.network "private_network", type: "dhcp"
  config.vm.hostname = "ansible.local"
  config.vm.provider "virtualbox" do |vb|
    vb.memory = "2048"
    vb.cpus = "2"
  end

  config.vm.synced_folder "..", "/vagrant", type: "virtualbox"
  config.vm.provision "shell", inline: $provisionning
end