Setting Up Vagrant and Registering a Chef Client Node with Chef server

Vagrant:

Vagrant is a ruby based supporting tool for interacting with VM solutions like  virtualbox ,vmware workstation etc,,Using vagrant we can configure a OS image (called box in vagrant terms) and can be be used by any other member in a development team. Each member in a development team need not install and configure the software’s needed for development, instead they can use the pre-configured vagrant box.Vagrant works well with virtual box and it is free of cost. If you want to use vagrant with vmware workstation and vmware fusion you have to pay for the licence. 

Settin up vagrant environment:

1)Download and install virtual box matching your OS type. In this tutorials am using ubuntu 12.04 server . Download here
2)Download and install vagrant. Download vagrant here
3) Now you have to set up your own box (os image) or you can download vagrant boxes (linux based) based on your requirement from here. Download Vagrant boxes here. If you want to make your own custom vagrant box , you can do it with veewee tool. Just have a look at this link .In this tutorial am goin to use the base box (ubuntu 12.04) provided by vagrant.
4)Download and add the vagrant base box using the following commad.It takes a while for downloading the box.
#syntax vagrant box add {boxname} {box provider url}
vagrant box add ubunt12.04 http://files.vagrantup.com/precise32.box

5)Now create a new directory for creating your new virtual machine. Let say chef-node

mkdir chef-node

6)cd in to chef-node directory and issude the following command to create the vagrant configuration file for the new virtual machine.

#syntax vagrant init {box-title}
vagrant init ubunt12.04
#the above command creates a vagrant file based on the base box titled ubunt12.04

7)To start the virtual machine, issue  <vagrant up > command in command line. Your virtual machine will be created in a minute.If you want your virtual machine to be in bridged connection, edit the vagrant file.

vagrant up

8) Using <vagrant ssh > command you can access your virtual machine.The default username and password of virtual machine will be “vagrant”

Vagrant ssh

If you want more than one vm , you can create a different directory and follow the same steps given above.

Registering a chef client node with chef-server using vagrant:

Relevant article: Setting up chef server and workstation

1)Create a vagrant file using <vagrant init boxname>.

2)Copy the validation.pem file from chef server to the node directory. Open the vagrant file using any editor and search for chef _client and edit the details there.

vagrant chef

3) Save the file and use <vagrant up> command. It will launch a vitual machine and register it with the chef server.

4)In chef workstation if you see the client list using knife cli, you can see the vagrant registered node in the chef server.

0 Shares:
Leave a Reply

Your email address will not be published. Required fields are marked *

You May Also Like