diff --git a/debian/README.md b/debian/README.md index 86200ddd..0955f4c4 100644 --- a/debian/README.md +++ b/debian/README.md @@ -1,7 +1,9 @@ # Learning Tools: Debian GNU/Linux -Here you'll find Vagrant environments and other resources for learning more about CoreOS. +Here you'll find Vagrant environments and other resources for learning more about Debian GNU/Linux. ## Contents **debian-generic**: This folder has a Vagrant environment for spinning up a generic, 64-bit Debian 8.0 ("Jessie") VM. Note there's nothing special here---just a plain, generic Debian VM. No custom provisioning is provided in this environment. + +**stretch-generic**: This folder has a Vagrant environment for spinning up a generic, 64-bit Debian 9.0 ("Stretch") VM. No custom provisioning is provided in this environment. diff --git a/debian/debian-generic/README.md b/debian/debian-generic/README.md index 3a0d116e..510442b1 100644 --- a/debian/debian-generic/README.md +++ b/debian/debian-generic/README.md @@ -1,6 +1,6 @@ -# Generic Debian 8.0 ("Jessie") VM +# Generic Debian 8.x ("Jessie") 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 Debian 8.0 ("Jessie") 64-bit VM. The configuration was tested using Vagrant 1.8.1 and 1.8.5, VMware Fusion 8.1.0 (with the Vagrant VMware plugin), and VirtualBox 5.1. +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 Debian 8.x ("Jessie") VM. This configuration was tested with VirtualBox, VMware Fusion, and the Vagrant Libvirt provider. **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 Debian VM for some purpose (building a package or testing a command). I'm including them here just for the sake of completeness. @@ -16,10 +16,10 @@ These files were created to allow users to use Vagrant ([http://www.vagrantup.co 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 a 64-bit Debian 8.0 ("Jessie") base box to be used by this `Vagrantfile`. You'll need to specify a box that provides support for the virtualization provider you're planning to use. +1. Use `vagrant box add` to add a 64-bit Debian 8.x ("Jessie") base box to be used by this `Vagrantfile`. You'll need to specify a box that provides support for the virtualization provider you're planning to use. The `machines.yml` file provides some suggested boxes to use. -2. Edit the `machines.yml` file to ensure the box you downloaded in step 1 is specified on the "box:" line of this file. +2. Edit the `machines.yml` file to ensure the box you downloaded in step 1 is specified on the "box:" section of this file. The "vmw" line is for a VMware-formatted box, the "vb" line is for the name of a VirtualBox-formatted box, and the "lv" line is for the name of a box that supports the Libvirt provider. Edit the appropriate line based on your virtualization provider and the name of the box you added in step 1. -3. Run `vagrant up`, and when the VM is up use `vagrant ssh` to access the generic Debian VM. +3. Run `vagrant up`, and when the VM is up use `vagrant ssh` to access the VM. Enjoy! diff --git a/debian/debian-generic/Vagrantfile b/debian/debian-generic/Vagrantfile index 20aecdc1..466ca79c 100644 --- a/debian/debian-generic/Vagrantfile +++ b/debian/debian-generic/Vagrantfile @@ -60,6 +60,16 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| vb.cpus = machine['vcpu'] override.vm.box = machine['box']['vb'] 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 diff --git a/debian/debian-generic/machines.yml b/debian/debian-generic/machines.yml index 1693e628..10ddd64b 100644 --- a/debian/debian-generic/machines.yml +++ b/debian/debian-generic/machines.yml @@ -1,7 +1,9 @@ --- -- name: "jessie" - box: - vmw: "slowe/debian-81-x64" +- box: + vmw: "bento/debian-8.2" vb: "debian/jessie64" + lv: "debian/jessie64" + name: "jessie" + nested: false ram: "1024" vcpu: "1" diff --git a/debian/stretch-generic/README.md b/debian/stretch-generic/README.md new file mode 100644 index 00000000..0d3c3faa --- /dev/null +++ b/debian/stretch-generic/README.md @@ -0,0 +1,25 @@ +# Generic Debian 9.x ("Stretch") 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 Debian 9.0 ("Stretch") VM. This configuration was tested with VirtualBox, VMware Fusion, and the Vagrant Libvirt provider. + +**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 Debian 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 a Debian 9.x ("Stretch") base box to be used by this `Vagrantfile`. You'll need to specify a box that provides support for the virtualization provider you're planning to use. The existing `machines.yml` file provides some suggested boxes. + +2. If you decide to use a box _other_ than one listed in `machines.yml`, edit `machines.yml` to specify the name of the box you added in step 1. In `machines.yml`, the "vmw" line is for a VMware-formatted box, the "vb" line is for the name of a VirtualBox-formatted box, and the "lv" line is for the name of a box that supports the Libvirt provider. Edit the appropriate line based on your virtualization provider and the name of the box you added in step 1. + +3. Run `vagrant up`, and when the VM is up use `vagrant ssh` to access the VM. + +Enjoy! diff --git a/debian/stretch-generic/Vagrantfile b/debian/stretch-generic/Vagrantfile new file mode 100644 index 00000000..466ca79c --- /dev/null +++ b/debian/stretch-generic/Vagrantfile @@ -0,0 +1,75 @@ +# -*- 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'] + 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 diff --git a/debian/stretch-generic/machines.yml b/debian/stretch-generic/machines.yml new file mode 100644 index 00000000..378d75dc --- /dev/null +++ b/debian/stretch-generic/machines.yml @@ -0,0 +1,9 @@ +--- +- box: + vmw: "bento/debian-9.2" + vb: "debian/stretch64" + lv: "debian/stretch64" + name: "stretch" + nested: false + ram: "1024" + vcpu: "1"