This tutorial is aimed at allowing you to create a Vagrant base box which contains Centos 7.0. Vagrant allows you to create and share virtual machines with anybody. There are two ways of using Vagrant boxes, either you create them or you can import one. You can import one from the internet or any other medium. In this tutorial I will show you how to create your own Centos 7.0 Vagrant box. I usually create my own boxes as it allows me to only install the software that I need or want.
2. Download Centos 7.0 (http://www.centos.org/download/). For the purpose of this tutorial I will be using the NetInstall ISO, but you may use any other ISO. I selected the NetInstall because of it’s small file size.
3. Create a new VM with VirtualBox. I have named mine centos7-vagrant.
You may setup this box any way you want. As far as settings are concerned, I have selected the following settings:
– Memory: 2GB
– Hard Disk: 20GB fixed size
4. Once your VM has been created go ahead and boot it up. It will ask you for a start-up disk. In my case I downloaded the NetInstall ISO. So I browsed and select CentOS-7.0-1406-x86_64-NetInstall.iso
5. Install Centos with any parameters you want. I selected a minimal install since I just want the basics and any special package that I need will be installed later.
6. Set the rootpassword as “vagrant”.
7. Create the vagrantuser. Set the username and password to “vagrant”
8. Once installation is finished and the VM restarts, login as root.
9. Now would be a good time to install the VirtualBoxGuest Additions. NOTE: This is an optional step.
10. Now we need to install packages that are essential for Vagrant to operate within the VM.
yum install-yopenssh-clients man git vim wget curl ntp
11. Let’s enable some services at startup time. We need ntpdso that it sets the time up correctly every time you boot up the Vagrant box, and of course sshd in order to SSH in.
chkconfig ntpd on&&chkconfig sshd on
12. Disable iptables as it really is not needed for a Vagrant box. It would just get in the way.
16. Create /etc/sysconfig/network-scripts/ifcfg-eth0 and add the following:
17. We must now add a public key for the vagrantuser. You can use the default public key or create a custom one. You may find more information on how to create a custom vagrant public key in the following tutorial “Using custom Vagrant SSH public/private keys“. For now we are going to use the readily available vagrantpublic key.
19. To create your Vagrant Box you will need to package the VM you just created. The following command will package the VM into your home directory. You are free to change this directory by modifying the –output paramenter