From c2b3b17343b70d4b3adb28921b9bbd0afc8d9255 Mon Sep 17 00:00:00 2001 From: Scott Lowe Date: Thu, 21 May 2015 08:53:37 -0600 Subject: [PATCH] Push "ubuntu-generic" folder Push changes for setting up a generic Ubuntu 14.04 VM (no tools or apps or other special configuration). --- ubuntu-generic/README.md | 25 ++++++++++++++++++++++++ ubuntu-generic/Vagrantfile | 39 ++++++++++++++++++++++++++++++++++++++ ubuntu-generic/servers.yml | 5 +++++ 3 files changed, 69 insertions(+) create mode 100644 ubuntu-generic/README.md create mode 100644 ubuntu-generic/Vagrantfile create mode 100644 ubuntu-generic/servers.yml diff --git a/ubuntu-generic/README.md b/ubuntu-generic/README.md new file mode 100644 index 0000000..f01003b --- /dev/null +++ b/ubuntu-generic/README.md @@ -0,0 +1,25 @@ +# Generic Ubuntu 14.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 14.04 64-bit VM. The configuration was tested using Vagrant 1.7.2, VMware Fusion 6.0.5, and the Vagrant VMware plugin. + +**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 + +* **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. + +* **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. + +1. Use `vagrant box add` to add an Ubuntu 14.04 base box to be used by this `Vagrantfile`. You can use my base box (`slowe/ubuntu-trusty-x64`), which provides support for the `vmware_desktop` provider (it should work with either VMware Workstation or VMware Fusion). + +2. If you are using a box other than my Ubuntu 14.04 base box, or if you want to change the default amount of RAM or number of vCPUs assigned to the VM, edit the `servers.yml` file and make the desired changes. + +3. Run `vagrant up`, and when the VM is up use `vagrant ssh` to access the generic Ubuntu 14.04 installation. + +Enjoy! diff --git a/ubuntu-generic/Vagrantfile b/ubuntu-generic/Vagrantfile new file mode 100644 index 0000000..ef80e71 --- /dev/null +++ b/ubuntu-generic/Vagrantfile @@ -0,0 +1,39 @@ +# -*- 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"] + + # Disable default synced folder + srv.vm.synced_folder ".", "/vagrant", disabled: 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/ubuntu-generic/servers.yml b/ubuntu-generic/servers.yml new file mode 100644 index 0000000..7fe4e47 --- /dev/null +++ b/ubuntu-generic/servers.yml @@ -0,0 +1,5 @@ +--- +- name: generic + box: slowe/ubuntu-trusty-x64 + ram: 1024 + vcpu: 1