Add Xenial Xerus environment

Add Xenial Xerus (16.04) environment that supports VMware, VirtualBox, and Libvirt

Signed-off-by: Scott Lowe <scott.lowe@scottlowe.org>
This commit is contained in:
Scott Lowe 2017-12-20 08:57:42 -07:00
parent f42c2df588
commit 768e6c4df0
No known key found for this signature in database
GPG key ID: 949F43F6E6C11780
4 changed files with 113 additions and 0 deletions

View file

@ -5,3 +5,5 @@ This folder contains materials for learning more about Ubuntu Linux.
## Contents
**ubuntu-generic**: This folder contains a Vagrant environment for spinning up a generic 64-bit Ubuntu 14.04 VM. Note there's nothing special going on here---just a plain, generic, Ubuntu VM. No custom provisioning is provided in this environment.
**xenial-generic**: This folder contains a Vagrant environment for spinning up a generic Ubuntu 16.04 VM. No custom provisioning is provided in this environment.

View file

@ -0,0 +1,25 @@
# Generic Ubuntu 16.04 VM
These files were created to allow users to use Vagrant ([http://www.vagrantup.com](http://www.vagrantup.com)) to quickly and easily spin up a generic Ubuntu 16.04 ("Xenial Xerus") VM. The configuration was tested with VMware Fusion, VirtualBox, and Libvirt.
**NOTE:** There's really nothing special here; I created these files because I often had a need to quickly and easily spin up a generic Ubuntu VM for some purpose (building a package or testing a command). I'm including them here just for the sake of completeness.
## Contents
* **machines.yml**: This YAML file contains a list of VM definitions and associated configuration data. It is referenced by `Vagrantfile` when Vagrant instantiates the VMs.
* **README.md**: This file you're currently reading.
* **Vagrantfile**: This file is used by Vagrant to spin up the virtual machines. This file is fairly extensively commented to help explain what's happening. You should be able to use this file unchanged; all the VM configuration options are stored outside this file.
## Instructions
These instructions assume you've already installed your virtualization provider (VMware Fusion/Workstation or VirtualBox), Vagrant, and any necessary plugins (such as the Vagrant VMware plugin). Please refer to the documentation for those products for more information on installation or configuration.
1. Use `vagrant box add` to add an Ubuntu 16.04 base box to be used by this `Vagrantfile`. The `machines.yml` file contains some suggested/recommended boxes.
2. If you are not using a box from `machines.yml`, edit `machines.yml` file to specify the Vagrant box you added in step 1 (the "vmw", "vb", and "lv" lines are for boxes formatted for VMware Fusion, VirtualBox, and Libvirt, respectively). You can also edit this file to change the amount of RAM allocated or the number of virtual CPUs assigned.
3. Run `vagrant up`, and when the VM is up use `vagrant ssh` to access the VM.
Enjoy!

77
ubuntu/xenial-generic/Vagrantfile vendored Normal file
View file

@ -0,0 +1,77 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Specify minimum Vagrant version and Vagrant API version
Vagrant.require_version '>= 1.6.0'
VAGRANTFILE_API_VERSION = '2'
# Require 'yaml' module
require 'yaml'
# 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
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# Always use Vagrant's default insecure key
config.ssh.insert_key = false
# 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']
# Specify the Vagrant box to use (use VMware box by default)
srv.vm.box = machine['box']['vmw']
# Configure default synced folder (disable by default)
if machine['sync_disabled'] != nil
srv.vm.synced_folder '.', '/vagrant', disabled: machine['sync_disabled']
else
srv.vm.synced_folder '.', '/vagrant', disabled: true
end #if machine['sync_disabled']
# Assign additional private network
if machine['ip_addr'] != nil
srv.vm.network 'private_network', ip: machine['ip_addr']
end # if machine['ip_addr']
# Configure CPU & RAM per settings in machines.yml (Fusion)
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'
# Configure CPU & RAM per settings in machines.yml (VirtualBox)
srv.vm.provider 'virtualbox' do |vb, override|
vb.memory = machine['ram']
vb.cpus = machine['vcpu']
override.vm.box = machine['box']['vb']
vb.customize ['modifyvm', :id, '--nictype1', 'virtio']
vb.customize ['modifyvm', :id, '--nictype2', 'virtio']
end # srv.vm.provider 'virtualbox'
# Configure CPU & RAM per settings in machines.yml (Libvirt)
srv.vm.provider 'libvirt' do |lv,override|
lv.memory = machine['ram']
lv.cpus = machine['vcpu']
override.vm.box = machine['box']['lv']
if machine['nested'] == true
lv.nested = true
end # if machine['nested']
end # srv.vm.provider 'libvirt'
end # config.vm.define
end # machines.each
end # Vagrant.configure

View file

@ -0,0 +1,9 @@
---
- box:
vmw: "generic/ubuntu1604"
vb: "ubuntu/trusty64"
lv: "generic/ubuntu1604"
name: "xenial"
nested: false
ram: "1024"
vcpu: "1"