From f05daa22b51dfdaaa7537e3536078c37fd22442c Mon Sep 17 00:00:00 2001 From: Scott Lowe Date: Wed, 6 May 2015 10:43:31 -0600 Subject: [PATCH] Commit initial support for LXD environment Add files for building a simple LXD environment via Vagrant --- lxd/README.md | 19 +++++++++++++++++++ lxd/Vagrantfile | 42 ++++++++++++++++++++++++++++++++++++++++++ lxd/servers.yml | 5 +++++ lxd/setup.sh | 17 +++++++++++++++++ 4 files changed, 83 insertions(+) create mode 100644 lxd/README.md create mode 100644 lxd/Vagrantfile create mode 100644 lxd/servers.yml create mode 100755 lxd/setup.sh diff --git a/lxd/README.md b/lxd/README.md new file mode 100644 index 0000000..d5906d2 --- /dev/null +++ b/lxd/README.md @@ -0,0 +1,19 @@ +# Running Containers with rkt + +These files were created to allow users to use Vagrant ([http://www.vagrantup.com](http://www.vagrantup.com)) quickly and relatively easily experiment with using `rkt` (pronounced "rock-it"), the CoreOS implementation of the App Container (appc) specification. 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 `rkt` 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 + +These instructions assume you've already installed VMware Fusion, Vagrant, and the Vagrant VMware plugin. Please refer to the documentation for those products for more information on installation or configuration. + +**[NOT YET COMPLETE]** diff --git a/lxd/Vagrantfile b/lxd/Vagrantfile new file mode 100644 index 0000000..ab14f35 --- /dev/null +++ b/lxd/Vagrantfile @@ -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 diff --git a/lxd/servers.yml b/lxd/servers.yml new file mode 100644 index 0000000..2ba0494 --- /dev/null +++ b/lxd/servers.yml @@ -0,0 +1,5 @@ +--- +- name: lxd-01 + box: slowe/ubuntu-trusty-x64 + ram: 512 + vcpu: 1 diff --git a/lxd/setup.sh b/lxd/setup.sh new file mode 100755 index 0000000..7810665 --- /dev/null +++ b/lxd/setup.sh @@ -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