Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jessereynolds/c4474f09a0ca53d96164d9339494be61 to your computer and use it in GitHub Desktop.
Save jessereynolds/c4474f09a0ca53d96164d9339494be61 to your computer and use it in GitHub Desktop.
Using Atom and Shared Folders in VirtualBox with the Puppet Fundamentals Student VM

Using Atom and Shared Folders in VirtualBox with the Puppet Fundamentals Student VM

First up, why might you want to do this? The main reason is this - you might prefer GUI text editors to command line text editors. Often when teaching Puppet Fundamentals some students will have littler or no command line experience and struggle with vim and nano. One alternative is to share a folder from your workstation (Mac, Windows or Linux) into the Linux vm we use for the course. This takes a little bit of setting up, which is where this document comes in.

An alternative to using shared folders, is to simply just use git to sync your local code up to the puppet master from your workstation.

Shared Folder Setup

  1. Be on the latest VirtualBox (these instructions tested with 5.0.24).

  2. Create the VM by importing the 2016.2.0-student-5.3 ova in VirtualBox.

  3. Select Bridged networking.

  4. Ensure there is an optical storage device configured for the VM.

  • the VM should be stopped
  • in VirtualBox click on Storage in the vm's settings
  • if there is no optical device listed, click the icon that looks like a compact disk with a green plus sign over it
  • click the 'leave empty' button
  1. Create the Shared Folder
  • in VirtualBox, click on Shared Folder s in the vm's settings
  • click the folder icon with the green plus symbol (add folder)
  • in Folder Path:, select the folder you want to share with the vm, eg a 'puppetcode' folder in your Documents folders
  • in Folder Name:, enter just 'puppetcode'
  • tick the 'Make Permament' checkbox, leave the others unchecked
  • in Atom, or your favourite text editor, create a text file named foo.txt within the shared folder. Enter some text into it and save it.
  1. Install the VirtualBox Guest Additions
  • Start the VM
  • Wait till you see the login prompt
  • Select Insert Guest Additions CD Image from the Device menu
  • ssh into the VM
  • mount the cd image: mkdir -p /cdrom && mount -t iso9660 /dev/cdrom /cdrom
  • run the installer cd /cdrom && sh ./VBoxLinuxAdditions.run
  1. Mount the shared folder
  • ensure the code directory exists: mkdir -p /root/puppetcode
  • run the following (within an ssh session into the vm): mount -t vboxsf puppetcode /root/puppetcode
  • verify you can see the contents of the foo.txt file from within the VM by running: cat /root/puppetcode/foo.txt
  • do a puppet run puppet agent -t
  1. Make the mount permament (mounted on boot)
  • Add the following line to /etc/fstab - puppetcode /root/puppetcode vboxsf defaults 0 0

Resetting the puppetcode directory

If you followed a previous version of these notes you may want to:

rm -rf /root/puppetcode

Then re-do the 'Mount the shared folder' steps above.

Puppet Setup

Download and install the Puppet Agent for your platform.

This is needed so you can validate syntax of puppet code locally, and to have a ruby environment installed that you can use.

Atom Setup

Download Atom and install it.

Install the following Atom packages:

  • language-puppet
  • linter
  • linter-puppet-lint
  • linter-erb
  • linter-puppet-parser
  • hiera-eyaml
  • aligner
  • aligner-puppet
  • aligner-ruby
  • git-plus
  • minimap

Packages can be installed from with Atom's Preferences (Settings) by selecting Install then entering the name of the package, searching for it, then clicking the Install button. Alternatively, the apm command can be used in a shell to install Atom packages, eg apm install language-puppet or to install multiple at once apm install language-puppet linter linter-puppet-lint ... etc

You can click the link within this interface to open a web browser with documentation on each package.

Instructor notes

When the host OS is Windows, the classroom::course::fundamentals class inclusion on the vms will cause puppet to attempt to fix the permissions under the /root/puppetcode directory, so students may be confused by many lines of output each puppet run that won't go away. So, once all student vms are set up, you can remove the matcher in the Classroom nodegroup so puppet stops trying to fix these permissions.

@beergeek
Copy link

Maybe you can share this with Ben Ford as well mate?

@binford2k
Copy link

I like this. We're currently exploring configuring graphical editors to connect to the git repo on the master, but this gives us some alternatives. Especially since 75% of this isn't really tied to a specific editor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment