Monthly Archives: October 2013

Vagrant Base Box setup using CentOS

Prerequisite for VM :

  1. VirtualBox Guest Additions(VirtualBox installed) or VMWare tool(VMWare installed).
  2. SSH with key-based auth support for the vagrant user.
  3. Vagrant user settings

Conventions over configuration if you plan to distribute this box
Hostname: vagrant-[os-name], e.g. vagrant-debian-lenny
Root Password: vagrant
Main account login: vagrant
Main account password: vagrant

OS: CentOS-6.2-i386-netinstall

Disable iPv6 support

URL setup

image file link

Set vagrant as the root password

export KERN_DIR=/usr/src/kernels/`uname -r`
yum install -y gcc make perl kernel-devel kernel-headers
yum update kernel* -u
shutdown -r now
require 'redcarpet'
markdown ="Hello World!")
puts markdown.to_html

install the VirtualBox Guest Additions

set vagrant user

groupadd admin
useradd -G admin vagrant

SSH configuration and user permission

echo "%admin ALL=NOPASSWD: ALL" >> /etc/sudoers
echo 'Defaults env_keep="SSH_AUTH_SOCK"' >> /etc/sudoers
vi /etc/sudoers

Add ! to the requiretty line. This enables vagrant to sudo remotely.

Default !requiretty

Add ssh public key

mkdir -m 0755 /home/vagrant/.ssh
$ curl -s > \> /home/vagrant/.ssh/authorized_keys
chmod 0644 /home/vagrant/.ssh/authorized_keys

Setup base box

cd ~/Documents/Virtual\ Machines.localized/.localized/
vagrant package --base Vagrant_Box_setup

[Vagrant_Box_setup] Clearing any previously set forwarded ports…
[Vagrant_Box_setup] Creating temporary directory for export…
[Vagrant_Box_setup] Exporting VM…
[Vagrant_Box_setup] Compressing package to: /Users/yoyo_chen/VirtualBox VMs/Vagrant_Box_setup/
Vagrant_Box_setup yoyo_chen$ vagrant box add test_box
Downloading or copying the box…
Extracting box…te: 17.2M/s, Estimated time remaining: 0:00:01)
Successfully added box ‘test_box’ with provider ‘virtualbox’!


Anyone who is interented in other OS platform can refer this
Debian OS iso
Building your own Base Box for Vagrant
Creating a vagrant base box for ubuntu 12.04 32bit server
Creating a CentOS 6.2 base box for Vagrant
Creating a CentOS 6.2 Base Box for Vagrant 1.1

Vagrant Official Doc
Base Box