mirror of
https://codeberg.org/scottslowe/learning-tools.git
synced 2026-03-11 09:04:37 +00:00
Commit changes for LXD-OVS environment
Commit initial changes for a learning environment using LXD with Open vSwitch (OVS)
This commit is contained in:
parent
85b8a6b901
commit
2edf938126
4 changed files with 85 additions and 0 deletions
21
lxd-ovs/README.md
Normal file
21
lxd-ovs/README.md
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
# 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.
|
||||
|
||||
## Contents
|
||||
|
||||
* **README.md**: This file you're currently reading.
|
||||
|
||||
* **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.
|
||||
|
||||
* **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.
|
||||
|
||||
* **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
|
||||
|
||||
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.
|
||||
|
||||
Enjoy working with LXD and OVS!
|
||||
42
lxd-ovs/Vagrantfile
vendored
Normal file
42
lxd-ovs/Vagrantfile
vendored
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
# -*- mode: ruby -*-
|
||||
# vi: set ft=ruby :
|
||||
|
||||
# Specify 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('servers.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
|
||||
servers.each do |servers|
|
||||
config.vm.define servers["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"
|
||||
|
||||
# Perform final provisioning activities
|
||||
srv.vm.provision "shell", path: "setup.sh", privileged: true
|
||||
|
||||
# Configure VMs with RAM and CPUs per settings in servers.yml
|
||||
srv.vm.provider :vmware_fusion do |vmw|
|
||||
vmw.vmx["memsize"] = servers["ram"]
|
||||
vmw.vmx["numvcpus"] = servers["vcpu"]
|
||||
end # srv.vm.provider
|
||||
end # config.vm.define
|
||||
end # servers.each
|
||||
end # Vagrant.configure
|
||||
5
lxd-ovs/servers.yml
Normal file
5
lxd-ovs/servers.yml
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
- name: lxd-01
|
||||
box: slowe/ubuntu-1404-x64-ovs
|
||||
ram: 512
|
||||
vcpu: 1
|
||||
17
lxd-ovs/setup.sh
Executable file
17
lxd-ovs/setup.sh
Executable file
|
|
@ -0,0 +1,17 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Initial housekeepting
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
# Add the PPA repository for LXD/LXC stable
|
||||
if [[ ! -e /etc/apt/sources.list.d/ubuntu-lxc-lxd-stable-trusty.list ]]; then
|
||||
sudo add-apt-repository -y ppa:ubuntu-lxc/lxd-stable
|
||||
fi
|
||||
|
||||
# Update package list
|
||||
sudo apt-get update
|
||||
|
||||
# Install LXC/LXD if not already installed
|
||||
if [[ ! -e /usr/bin/lxd ]]; then
|
||||
sudo apt-get -y install lxd
|
||||
fi
|
||||
Loading…
Reference in a new issue