Introduction

Vagrant allows you to test things to run on NeCTAR virtuals on your own desktop or laptop.  This page assumes that you already understand Chef and Berkshelf, and that you have already installed Vagrant on your development machine.

There are two ways to use Chef with Vagrant, depending on what you are trying to achieve.

Installing Chef & Berkshelf into a Vagrant virtual.

In this approach, we create a Vagrant virtual, and then "bootstrap" it with Chef and Berkshelf so that you can use the virtual for testing cookbooks and associated installation procedures.

Instructions for doing this may be found here.  Note that there is now a "bootstrap.sh" file that scripts the Chef + Berkshelf bootstrapping procedure.

Once this is completed, you will have a virtual that is minimally configured.  You would then typically:

  1. connect to the instance using "vagrant ssh"
  2. go to the "repo" directory
  3. edit the Berksfile to add any cookbook dependencies that you need
  4. edit the "mynode.json" file to add change node attributes and/or the runlist, and
  5. run chef-solo.

Using Chef & Berkshelf to provision the Vagrant virtual.

In this model, we provision the Vagrant virtual directly from a Berkshelf on your workstation / laptop. 

For now, see the instructions on the Berkshelf site here.

This is procedure is likely to get you a provisioned virtual faster, but you (typically) won't have the tools on the virtual to allow you to rerun the Chef recipes.  Instead, you will need to:

  1. shutdown the Vagrant instance,
  2. make any required changes to the Chef artefacts that you are using, and
  3. relaunch the Vagrant instance like this to force the Chef recipes to be rerun:

    vagrant up --provision

Differences between Vagrant and NeCTAR virtuals

I've noticed a couple of differences (so far):

  • The virtuals that are created by Vagrant tend to have fewer packages initially installed.  For example, I found that I needed to install "curl" on the Vagrant flavour of Ubuntu (precise32).
  • The default user account is different - "vagrant" password: "vagrant".
  • Unless you have tweaked the networking, a Vagrant virtual will typically have an IP address that is unknown to the local DNS.  This means that setting "node['setup']['set_fqdn']" to "*" in the node.json file will not work.  Set it to whatever you want the hostname to be.  (But note that things that depend on being able to do a proper DNS lookup of the chosen name are liable to fail.)