Skip to content

Instantly share code, notes, and snippets.

@jlank
Created August 31, 2012 16:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jlank/3555523 to your computer and use it in GitHub Desktop.
Save jlank/3555523 to your computer and use it in GitHub Desktop.
Building a CentOS 6 Box for Vagrant
  1. * coding: utf-8 *

Download net install iso. Find a mirror close to you at http://isoredirect.centos.org/centos/6/isos/x86_64/

Create a new VirtualBox machine

- Name: vagrant-centos
- Operating System: Linux
- Version: Red Hat 64bit

- Base Memory Size: 768 Mb
- Dynamically expanding hard disk: 40Gb

- Disable Audio
- Disable USB
- Make sure network is set to NAT
- Attach the net install ISO to the CDROM so it can boot

Run through install procedure

- Install system
- Skip verification
- Installation Method: HTTP
- Disable IPv6, leave IPv4 enabled with DHCP
- HTTP Setup:
URL: http://mirror.centos.org/centos/6/os/x86_64/

- Initialize drive and erase data: yes
- Configure network: yes
– Set hostname to vagrant-centos
- Root password: vagrant
- Select minimal setup (click continue, this will take a while)
- Remove CDRom media
- Reboot
- Disable firewall

Dependencies

Basic

- yum install curl ftp rsync sudo time wget which git-core

VirtualBox additions

- yum install gcc bzip2 make kernel-devel-`uname -r`
- From the menu: Devices → Install Guest Additions…
- sudo mount -o ro -t iso9660 /dev/cdrom /mnt
- sudo sh /mnt/VBoxLinuxAdditions.run
- Will complain about X related drivers we didn’t install. Should be fine.
- If you need to recompile, run this within the VM /etc/init.d/vboxadd setup and then vagrant reload

NFS

- yum install nfs-utils
- chkconfig rpcbind on
- chkconfig nfslock on

Ruby

- yum install gcc-c++ zlib-devel openssl-devel readline-devel sqlite3-devel

Users

Add vagrant

- groupadd admin
- useradd -G admin vagrant
- passwd vagrant # choose “vagrant” as the password

visudo

- Add the following lines at the bottom:

  1. Vagrant user should be able to sudo
    %admin ALL=NOPASSWD: ALL

- Comment out the following line:

  1. Defaults requiretty # (otherwise ssh doesn’t work)
  1. Add the variable “PATH” to the “Defaults env_keep” list, otherwise sudo cleans the path, and loses ruby, which ohai needs
  1. Add the /usr/sbin and /sbin to the path
    echo ‘export PATH=$PATH:/usr/sbin:/sbin’ >> ~vagrant/.bashrc

Enable NFS support

Install RVM, Ruby 1.9.2-p290 and Chef

- curl -L https://get.rvm.io | bash -s stable —ruby
- source .bash_profile
- rvm install 1.9.2-p290
- rvm default 1.9.2
- rvm use 1.9.2
- gem install chef —no-ri —no-doc

Add Vagrant’s “insecure” public key

As user vagrant

mkdir .ssh
chmod 755 .ssh
curl https://raw.github.com/mitchellh/vagrant/master/keys/vagrant.pub > .ssh/authorized_keys
chmod 644 .ssh/authorized_keys

Clean up

- sudo yum clean headers packages dbcache expire-cache
- halt

Export and package

Follow instructions on http://vagrantup.com/docs/base_boxes.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment