Last Updated: February 25, 2016
· emil

Testing Chef on Multiple Environments using Vagrant

I'm doing a lot of things with Chef in my current project, and I was looking for a way to test the client-server architecture of Chef . I could get hold of a couple of unused machines from the IT guys , but that isn't such a cool thing to do.

How about this - multiple environments in my own development machine, which I can screw up to my heart's content , erase everything and restart my test as many times as I want in a flash ? That would be sweet !

Say hello to Vagrant . I have Vagrant set up in my machine , and you should have it too . If you haven't done that already , this post will help you do just that.

Enough chit chat , let's figure out the multi-environment thingy .

I want two independent virtualmachines, one running lucid32 another running precise32 , just for the demo. I’m going to use these as my chef-clients to test out Chef.

I destroyed my existing VM by running :

vagrant destroy

Modified my Vagrantfile to look like this: do |config|
  config.vm.define :node1 do |node_config| = "lucid32" :bridged

  config.vm.define :node2 do |node_config| = "precise32" :bridged

lucid32 machine is node1 and precise32 is node2

In one terminal tab , I run :
vagrant up node1
vagrant ssh node1

and in a second tab :

vagrant up node2
vagrant ssh node2

There you go .