Update README.md and Vagrantfile for KVM-based environments

For KVM-based environments (which require nested virtualization support), update the README.md to note that VirtualBox is not supported. Also update the Vagrantfile for clearer indications that only VMware-based providers are supported.
This commit is contained in:
Scott S. Lowe 2016-10-03 19:33:49 -06:00
parent daafe0b704
commit f06de99342
4 changed files with 38 additions and 20 deletions

View file

@ -2,6 +2,8 @@
These files were created to allow users to use Vagrant ([http://www.vagrantup.com](http://www.vagrantup.com)) and Ansible ([http://www.ansible.com](http://www.ansible.com)) to quickly and relatively easily experiment with KVM networking using macvtap interfaces on Ubuntu 14.04 LTS. This configuration was tested using Vagrant 1.8.1, VMware Fusion 8.1.0, the Vagrant VMware plugin, and Ansible 1.9.1. Other versions of these products are likely to work, but haven't been tested.
Note that this environment does **not** work with VirtualBox, as it relies on support for nested virtualization (which VirtualBox does not support).
## Contents
* **ansible.cfg**: This Ansible configuration file instructs Ansible to use the Vagrant-generated inventory file (by default in `./.vagrant/provisioners/inventory/vagrant_ansible_inventory`), to use the default vagrant user (`vagrant`) and default insecure Vagrant SSH private key.

View file

@ -1,17 +1,18 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Specify Vagrant version, Vagrant API version, and desired clone location
# VirtualBox is not included here because it does not support nested virt
# Specify minimum Vagrant version and Vagrant API version
Vagrant.require_version '>= 1.6.0'
VAGRANTFILE_API_VERSION = '2'
# Explicitly specify the VMware provider (req'd for nested virtualization)
ENV['VAGRANT_DEFAULT_PROVIDER'] = 'vmware_fusion'
ENV['VAGRANT_VMWARE_CLONE_DIRECTORY'] = '~/.vagrant'
# Require 'yaml' module
require 'yaml'
# Read YAML file with VM details (box, CPU, and RAM)
# Read YAML file with VM details (box, CPU, RAM, IP addresses)
# Edit machines.yml to change VM configuration details
machines = YAML.load_file(File.join(File.dirname(__FILE__), 'machines.yml'))
# Create and configure the VMs
@ -22,12 +23,18 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# Iterate through entries in YAML file to create VMs
machines.each do |machine|
# Configure the VMs per details in machines.yml
config.vm.define machine['name'] do |srv|
# Don't check for box updates
srv.vm.box_check_update = false
# Specify the hostname of the VM
srv.vm.hostname = machine['name']
srv.vm.box = machine['box']
# Specify the Vagrant box to use (must use VMware box)
srv.vm.box = machine['vmw_box']
# Configure default synced folder (disable by default)
if machine['sync_disabled'] != nil
@ -42,13 +49,13 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
end # if machine['ip_addr']
# Configure CPU & RAM per settings in machines.yml (Fusion)
srv.vm.provider :vmware_fusion do |vmw|
srv.vm.provider 'vmware_fusion' do |vmw|
vmw.vmx['memsize'] = machine['ram']
vmw.vmx['numvcpus'] = machine['vcpu']
if machine['nested'] == true
vmw.vmx['vhv.enable'] = 'TRUE'
end #if machine['nested']
end # srv.vm.provider vmware_fusion
# Enable nested virtualization (required for KVM)
vmw.vmx['vhv.enable'] = 'TRUE'
end # srv.vm.provider 'vmware_fusion'
# Provision the VM with Ansible if enabled in machines.yml
if machine['provision'] != nil

View file

@ -2,6 +2,8 @@
These files were created to allow users to use Vagrant ([http://www.vagrantup.com](http://www.vagrantup.com)) and Ansible ([http://www.ansible.com](http://www.ansible.com)) to quickly and relatively easily experiment with KVM on Ubuntu 14.04 LTS. This configuration was tested using Vagrant 1.8.1, VMware Fusion 8.1.0, the Vagrant VMware plugin, and Ansible 1.9.1. Other versions of these products are likely to work, but haven't been tested.
Note that this environment does **not** work with VirtualBox, as it relies on support for nested virtualization (which VirtualBox does not support).
## Contents
* **ansible.cfg**: This Ansible configuration file instructs Ansible to use an inventory file named `hosts` in the current directory, to use the default vagrant user (`vagrant`) and default insecure Vagrant SSH private key, and to use the Vagrant-generated Ansible inventory file (found, by default, in `./.vagrant/provisioners/inventory/vagrant_ansible_inventory`).

27
kvm/Vagrantfile vendored
View file

@ -1,17 +1,18 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Specify Vagrant version, Vagrant API version, and desired clone location
# VirtualBox is not included here because it does not support nested virt
# Specify minimum Vagrant version and Vagrant API version
Vagrant.require_version '>= 1.6.0'
VAGRANTFILE_API_VERSION = '2'
# Explicitly specify the VMware provider (req'd for nested virtualization)
ENV['VAGRANT_DEFAULT_PROVIDER'] = 'vmware_fusion'
ENV['VAGRANT_VMWARE_CLONE_DIRECTORY'] = '~/.vagrant'
# Require 'yaml' module
require 'yaml'
# Read YAML file with VM details (box, CPU, and RAM)
# Read YAML file with VM details (box, CPU, RAM, IP addresses)
# Edit machines.yml to change VM configuration details
machines = YAML.load_file(File.join(File.dirname(__FILE__), 'machines.yml'))
# Create and configure the VMs
@ -22,12 +23,18 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# Iterate through entries in YAML file to create VMs
machines.each do |machine|
# Configure the VMs per details in machines.yml
config.vm.define machine['name'] do |srv|
# Don't check for box updates
srv.vm.box_check_update = false
# Specify the hostname of the VM
srv.vm.hostname = machine['name']
srv.vm.box = machine['box']
# Specify the Vagrant box to use (must use VMware box)
srv.vm.box = machine['vmw_box']
# Configure default synced folder (disable by default)
if machine['sync_disabled'] != nil
@ -42,13 +49,13 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
end # if machine['ip_addr']
# Configure CPU & RAM per settings in machines.yml (Fusion)
srv.vm.provider :vmware_fusion do |vmw|
srv.vm.provider 'vmware_fusion' do |vmw|
vmw.vmx['memsize'] = machine['ram']
vmw.vmx['numvcpus'] = machine['vcpu']
if machine['nested'] == true
vmw.vmx['vhv.enable'] = 'TRUE'
end #if machine['nested']
end # srv.vm.provider vmware_fusion
# Enable nested virtualization (required for KVM)
vmw.vmx['vhv.enable'] = 'TRUE'
end # srv.vm.provider 'vmware_fusion'
# Provision the VM with Ansible
config.vm.provision 'ansible' do |ansible|