Vagrant:
Settin up vagrant environment:
#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:
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.
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.