diff --git a/kvm-macvtap/README.md b/kvm-macvtap/README.md index 530407f..1e8a53e 100644 --- a/kvm-macvtap/README.md +++ b/kvm-macvtap/README.md @@ -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. diff --git a/kvm-macvtap/Vagrantfile b/kvm-macvtap/Vagrantfile index 028ccec..695ded5 100644 --- a/kvm-macvtap/Vagrantfile +++ b/kvm-macvtap/Vagrantfile @@ -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 diff --git a/kvm/README.md b/kvm/README.md index abe944a..42647d7 100644 --- a/kvm/README.md +++ b/kvm/README.md @@ -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`). diff --git a/kvm/Vagrantfile b/kvm/Vagrantfile index 3648b75..a0408dc 100644 --- a/kvm/Vagrantfile +++ b/kvm/Vagrantfile @@ -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|