Creating a custom vagrant box is easy. Start with obtaining an iso and installing it in a hypervizor. Here, I choose a Debian, http://cdimage.debian.org/debian-cd/8.1.0/amd64/iso-cd/debian-8.1.0-amd64-netinst.iso, debian-8.1.0-amd64-netinst.iso in Oracle VM Virtual Box.

Create a virtual machine named vagrant-debian81-raring having 512 MB memory with creating a virtual hard drive. Remember that base settings such as memory may easily be incremented through individual Vagrant implementation. Here I will choose 40 GB dynamically allocated virtual machine disk file type.

vagrant basebox - creating a vm

Some conventions are setting host name to vagrant-debian81-raring with domain vagrantup.com. Again these may be overridden in Vagrant configuration later. Root password should be vagrant, and a user vagrant should be created with password vagrant. We have option to use ssh authentication later if we desire passwordless connection.

vagrant basebox - vm settings

Since Vagrant needs ssh connection, shh server should be installed in virtual machine.

vagrant basebox - vm settings II

Vagrant also needs guest additions to perform. First install linux headers and build essentials,

vagrant basebox - installing guest extensions

Then guest additions may be installed through first pointing the necessary iso in hypervizor, then mounting the device and running the installation script as follows,

vagrant basebox - installing guest extensions II

Vagrant may use passwordless ssh authentication. In order to perform this, create a new group admin and make vagrant user belong to group admin.

vagrant basebox - creating group admin

Then, modify /etc/sudoers through visudo to give members of admin group passwordless privileges,

vagrant basebox - sudoers passwordless privileges

Puppet will be handy in elegant provisioning, so it is better to install it. It will also be good to test if vagrant is able to do privilege jobs without password (after a logout / login).

vagrant basebox - installing puppet

And as a last step, put default public keys of vagrant to virtual machine.

vagrant basebox - placing public key

We clean temporary files

vagrant basebox - cleaning

And make virtual machine a vagrant box with;

vagrant basebox - creating vagrant base

This should create package.box in working directory which is d:\ in my case. Now, let’s add this new box into vagrant base box list,

vagrant basebox - adding to box list

Now, let’s use newly created base to prepare a system for mooc M101JS: MongoDb for NodeJs developers, https://university.mongodb.com/courses/M101JS/about,

vagrant basebox - vagrant init

I will modify vagrantfile and default.pp to make sure nodejs and mongodb is installed. More information about provisioning may be seen in an earlier blog, https://sifaserdarozen.wordpress.com/2015/07/10/cultivating-a-development-system-through-vagrant-puppet/

vagrant basebox - vagrantfile

After provisioning, our system is ready for the course,

vagrant basebox - vagrant up

vagrant basebox - mongodb