Remove reference to personally-maintained box

Change servers.yml to machines.yml for consistency with other learning environments. Remove all references to personally-maintained base boxes.

Signed-off-by: Scott Lowe <scott.lowe@scottlowe.org>
This commit is contained in:
Scott Lowe 2016-12-04 00:58:43 -07:00
parent 14cf0c337a
commit 477310a284
5 changed files with 65 additions and 36 deletions

View file

@ -1,12 +1,12 @@
# Running LXC-Based OS Containers with LXD and Open vSwitch
These files were created to allow users to use Vagrant ([http://www.vagrantup.com](http://www.vagrantup.com)) quickly and relatively easily experiment with LXD (pronounced "lex-dee"), a new daemon and CLI client for working with LXC-based OS containers, along with Open vSwitch, aka OVS ([http://openvswitch.org](http://openvswitch.org)). The configuration was tested using Vagrant 1.7.2, VMware Fusion 6.0.5, and the Vagrant VMware plugin.
These files were created to allow users to use Vagrant ([http://www.vagrantup.com](http://www.vagrantup.com)) quickly and relatively easily experiment with LXD (pronounced "lex-dee"), a new daemon and CLI client for working with LXC-based OS containers, along with Open vSwitch, aka OVS ([http://openvswitch.org](http://openvswitch.org)). The configuration was tested using Vagrant 1.8.7, VMware Fusion 8.1.0, and the Vagrant VMware plugin.
## Contents
* **README.md**: This file you're currently reading.
* **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. No changes should be necessary to use this file.
* **servers.yml**: This YAML file contains a list of VM definitions and associated configuration data. It is referenced by `Vagrantfile` when Vagrant instantiates the VMs. No changes should be necessary to use this file.
* **README.md**: This file you're currently reading.
* **setup.sh**: This shell script is called by the Vagrant shell provisioner and configures LXD inside the VM created by Vagrant. No changes should be needed to this file.
@ -16,6 +16,6 @@ These files were created to allow users to use Vagrant ([http://www.vagrantup.co
This learning environment is exactly the same as the LXD learning environment (found in the `lxd` directory of my "learning-tools" GitHub repository), but adds OVS to the base box. This will enable you to leverage LXD/LXC's built-in support for OVS by specifying the name of an OVS bridge on the "parent:" line of a bridged network interface in the container's profile.
I have an Ubuntu 14.04 x64 with OVS base box that can be used; just be sure that "slowe/ubuntu-1404-x64-ovs" is specified in the `servers.yml` file as the name of the box Vagrant should use.
Use `vagrant box add` to add an Ubuntu 14.04 base box. For a VMware-formatted box, the "bento/ubuntu-14.04" box is one good option. For a VirtualBox-formatted box, use the "ubuntu/trusty64" box. Just be sure the appropriate box name(s) are put into the `machines.yml` file before running `vagrant up`.
Enjoy working with LXD and OVS!

72
lxd-ovs/Vagrantfile vendored
View file

@ -1,18 +1,15 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Specify Vagrant version, Vagrant API version, and Vagrant clone location
Vagrant.require_version ">= 1.6.0"
VAGRANTFILE_API_VERSION = "2"
ENV['VAGRANT_VMWARE_CLONE_DIRECTORY'] = '~/.vagrant'
ENV['VAGRANT_DEFAULT_PROVIDER'] = 'vmware_fusion'
#ENV['VAGRANT_DEFAULT_PROVIDER'] = 'virtualbox'
# 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, and RAM)
servers = YAML.load_file(File.join(File.dirname(__FILE__), 'servers.yml'))
machines = YAML.load_file(File.join(File.dirname(__FILE__), 'machines.yml'))
# Create and configure the VMs
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
@ -21,31 +18,52 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.ssh.insert_key = false
# Iterate through entries in YAML file to create VMs
servers.each do |servers|
config.vm.define servers["name"] do |srv|
machines.each do |machine|
config.vm.define machine['name'] do |srv|
# Don't check for box updates
srv.vm.box_check_update = false
srv.vm.hostname = servers["name"]
srv.vm.box = servers["box"]
# Enable default synced folder
srv.vm.synced_folder ".", "/vagrant"
# Set VM hostname
srv.vm.hostname = machine['name']
# Set 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']
# Iterate through networks as per settings in machines.yml
machine['nics'].each do |net|
if net['ip_addr'] == 'dhcp'
srv.vm.network net['type'], type: net['ip_addr']
else
srv.vm.network net['type'], ip: net['ip_addr']
end # if net['ip_addr']
end # machine['nics'].each
# 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']
end # srv.vm.provider 'virtualbox'
# Perform final provisioning activities
srv.vm.provision "shell", path: "setup.sh", privileged: true
# Configure VMs with RAM and CPUs per settings in servers.yml (Fusion)
srv.vm.provider :vmware_fusion do |vmw|
vmw.vmx["memsize"] = servers["ram"]
vmw.vmx["numvcpus"] = servers["vcpu"]
end # srv.vm.provider vmware_fusion
# Configure VMs with RAM and CPUs per settings in servers.yml (VirtualBox)
srv.vm.provider :virtualbox do |vb|
vb.memory = servers["ram"]
vb.cpus = servers["vcpu"]
end # srv.vm.provider virtualbox
srv.vm.provision 'shell', path: 'setup.sh', privileged: true
end # config.vm.define
end # servers.each
end # machines.each
end # Vagrant.configure

11
lxd-ovs/machines.yml Normal file
View file

@ -0,0 +1,11 @@
---
- box:
vmw: "bento/ubuntu-14.04"
vb: "ubuntu/trusty64"
name: "lxd-01"
nested: false
nics:
- type: "private_network"
ip_addr: "dhcp"
ram: "512"
vcpu: "1"

View file

@ -1,5 +0,0 @@
---
- name: lxd-01
box: slowe/ubuntu-1404-x64-ovs
ram: 512
vcpu: 1

View file

@ -15,3 +15,8 @@ sudo apt-get update
if [[ ! -e /usr/bin/lxd ]]; then
sudo apt-get -y install lxd
fi
# Install OVS if not already installed
if [[ ! -e /usr/bin/ovs-vsctl ]]; then
sudo apt-get -y install openvswitch-common openvswitch-switch
fi