Linux Developer VM Example / Template
A minimal example / template project for a Chef-managed Linux Developer VM.
It's meant to be copy/pasted and filled with life. The
contains the recipes for setting up the VM and the tests that come along with it.
All your specific customizations go in there!
This is just a bare skeleton template project. For more concrete / real life examples please refer to:
These are the main tools included in this developer VM (see CHANGELOG for the specific versions):
- ChefDK - for managing / installing this developer VM
- VIM - the most minimal development toolchain I could come up with ;-)
Tweaks and Settings
Other tweaks and settings worth mentioning:
- places a
README.mdfile on the Desktop to guide first time users after they logged in to the VM
/usr/local/bin/update-vmso it's in the
$PATHand can be used for updating the VM from the inside (see below)
Obtaining and Starting the VM Image
The latest version of this developer VM can be downloaded as a VM image from here:
After downloading the .ova file you can import it into VirtualBox via
File -> Import Appliance....
Once imported, you can simply start the VM and log in:
- username: "vagrant"
- password: "vagrant"
From then on just open a terminal and you will have all of the tools available (see "What's included?").
Updating the VM
You can run these commands from anywhere inside the developer VM:
update-vm- update the VM by applying the Chef recipes from the locally checked out repo at
update-vm --pull- same as above, but update repo before by pulling the latest changes
update-vm --verify-only- don't update the VM, only run the Serverspec tests
update-vm --provision-only- don't run the Serverspec tests, only update the vm
Keyboard Layout and Locale Settings
The VM ships with a full
US keyboard layout and
en_US.UTF-8 locale by default.
To change the keyboard layout to your preferred language use
System Settings... -> Text Entry in the VM.
If you have a totally different keymap (e.g. on a MacBook) you can always reconfigure it:
sudo dpkg-reconfigure keyboard-configuration
If want to reconfigure the locale:
sudo dpkg-reconfigure locales
All other requirements, including with ChefDK will be installed inside the Vagrant VM during provisioning, i.e. you don't need them installed on your host machine.
Basic Development Workflow
Bring up the developer VM:
$ vagrant up
This will take a while, as it will do quite a few things inside the VM:
- Download and install ChefDK
- Copy the current directory into the VM (will be placed in
- Install cookbook dependencies via Berkshelf to
- Trigger a Chef-Zero run to apply the
~/vm-setup/cookbooks/vm/recipesto the VM (see "What's included?")
- Verify the installation using a set of Serverspec tests
Watch the vagrant output on the console for seeing progress. At the end you should see all tests passing:
... ==> default: vm::base ==> default: places a README on the Desktop ==> default: ==> default: vm::vim ==> default: installs Vi IMproved ==> default: ==> default: update-vm.sh ==> default: installs chefdk 1.3.32 ==> default: symlinks the update-vm script to /usr/local/bin/ ==> default: ==> default: Finished in 0.09228 seconds (files took 0.59519 seconds to load) ==> default: 4 examples, 0 failures
If these are passing as expected, you can continue developing on the Chef recipes within this repo. Please don't forget to add a test for each new feature you add (see "Contributing")
Whenever you feel like distributing a fat VM image rather than a Vagrantfile, you can package / export it as a VirtualBox image. This might be useful for distributing the initial version of the developer VM to your dev team, or simply for preserving checkpoint releases as a binary images.
Let's start from a clean state:
$ vagrant destroy -f $ vagrant up
This will provision the VM as usual. Once the provisioning succeeded, we will do a few cleanup steps before packaging the VM.
First, unmount the /vagrant shared folder:
$ vagrant ssh -c "sudo umount /vagrant -f"
Finally, shutdown the VM, remove the sharedfolder, and export the VM as an .ova file:
$ vagrant halt $ VBoxManage sharedfolder remove "Linux Developer VM" --name "vagrant" $ VBoxManage modifyvm "Linux Developer VM" --name "Linux Developer VM v0.1.0" $ VBoxManage export "Linux Developer VM v0.1.0" --output "linux-developer-vm-v0.1.0.ova" --options manifest,nomacs
Don't forget to throw away the VM when you are done:
$ vagrant destroy -f
- Fork the repository on Github
- Create a named feature branch (like
- Implement your changes, add tests
- Commit and push
- Submit a Pull Request via Github