Skip to content

Latest commit

 

History

History
169 lines (127 loc) · 7.33 KB

README.md

File metadata and controls

169 lines (127 loc) · 7.33 KB

Linus' Kitchen

Circle CI

An Ubuntu Desktop 14.04 based development box for Infrastructure-as-Code development with Vagrant, Chef & Co.

Linus' Kitchen Screenshot

Yes, it is being set up with Vagrant and Chef, so it's a bit meta... It is also the Linux based equivalent of the Bill's Kitchen DevPack.

Prerequisites

You only need VirtualBox and Vagrant installed.

All other requirements, along with ChefDK and Git will be installed inside the Vagrant VM during provisioning, i.e. you don't need them installed on your host machine.

Basic Usage

Bring up the linus-kitchen VM:

$ vagrant up

This will take a while, as it will do quite a few things inside the VM:

  1. Download and install Git and ChefDK
  2. Copy the current directory into the VM (will be placed in ~/vm-setup)
  3. Install cookbook dependencies via Berkshelf to ~/vm-setup/cookbooks/vm/cookbooks
  4. Trigger a Chef-Zero run to apply the ~/vm-setup/cookbooks/vm/recipes to the VM (see "What's included?")
  5. Verify the installation using a battery of Serverspec tests

Watch the vagrant output on the console for seeing progress. At the end you should see all tests passing:

...
==> default:
==> default: update-vm.sh
==> default:   installs git
==> default:   installs chefdk 0.7.0
==> default:
==> default: Finished in 24.44 seconds (files took 0.81272 seconds to load)
==> default: 33 examples, 0 failures
...

You can now log in to the Desktop (the VM is started in GUI mode):

  • user: "vagrant"
  • password: "vagrant"

Once logged in, you can open a terminal and you will have all of the tools available (see next section).

What's included?

These are the main tools included in Linus' Kitchen:

Other tweaks worth mentioning:

  • Scripts in ~/.bash.d/*.sh are sourced from ~/.bashrc, pre-configured with the following:
  • set up be as an alias for bundle exec
  • run chef shell-init bash for initializing the ChefDK
  • configure "docker" as the $VAGRANT_DEFAULT_PROVIDER
  • Bundler is configured for parallel downloading and retrying (see ~/.bundle/config)
  • Customized Atom config, e.g. with SublimeText-like tab behaviour (see ~/.atom/config.cson)
  • Customized ~/.vagrant.d/Vagrantfile and ~/.kitchen/config.yml for caching as much as possible
  • Pre-installed Vagrant plugins:
  • Pre-installed Atom plugins:
  • Symlinked update-vm.sh to /usr/local/bin/update-vm so it's in the $PATH and can be used for updating the VM from the inside (see below)

Updating Linus' Kitchen

Even though you can trigger an update from outside the VM via vagrant provision, you usually want to do that from inside the VM as this is your current working environment. The update is done via Chef so it should be fully idempotent.

You can run these commands from anywhere inside the VM:

  • update-vm - to apply the Chef recipes of the locally checked out linus-kitchen repo in ~/vm-setup
  • update-vm --pull - same as above but update the repo before
  • update-vm --verify-only - don't update the VM, only run the Serverspec tests

Acceptance Test

In addition to the Serverspec tests (which verify that the installed tools are properly configured and working as expected) you can also execute a minimal acceptance test which covers the common usage scenarios when developing with Vagrant and Chef, including:

The acceptance test is not run by default, but you can run it manually from anywhere inside the VM:

$ git clone https://github.com/tknerr/vagrant-workflow-tests
$ cd vagrant-workflow-tests
$ rspec

If all goes well you should see an output like this.

Keyboard Layout

Seems to be too hard to automate for me, so you have to do this manually for now:

sudo dpkg-reconfigure keyboard-configuration

Packaging

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.

First, start from a clean state, and make sure vagrant-cachier is disabled:

$ vagrant destroy -f
$ export VAGRANT_NO_PLUGINS=1
$ vagrant up

Next, unmount the /vagrant shared folder (will be restored on next vagrant up):

$ vagrant ssh -c "sudo umount /vagrant"

Also, you may want to clean out the VM for a minimal export image:

$ vagrant ssh -c "wget -qO- https://raw.githubusercontent.com/boxcutter/ubuntu/master/script/cleanup.sh | sudo bash"

Finally, shutdown the VM, remove the sharedfolder, and export the VM as an .ova file:

$ vagrant halt
$ VBoxManage sharedfolder remove "Linus Kitchen" --name "vagrant"
$ VBoxManage modifyvm "Linus Kitchen" --name "Linus Kitchen v0.1"
$ VBoxManage export "Linus Kitchen v0.1" --output "linus-kitchen-v0.1.ova" --options manifest,nomacs

Don't forget to throw away the VM enable vagrant-cachier again:

$ vagrant destroy -f
$ unset VAGRANT_NO_PLUGINS

Contributing

  1. Fork the repository on Github
  2. Create a named feature branch (like add-xyz)
  3. Implement your changes, add tests
  4. Commit and push
  5. Submit a Pull Request using Github