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.
-
Be on the latest VirtualBox (these instructions tested with 5.0.24).
-
Create the VM by importing the 2016.2.0-student-5.3 ova in VirtualBox.
-
Select Bridged networking.
-
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
- 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.
- 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
- 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
- Make the mount permament (mounted on boot)
- Add the following line to /etc/fstab -
puppetcode /root/puppetcode vboxsf defaults 0 0
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.
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.
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.
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.
Maybe you can share this with Ben Ford as well mate?