Skip to content

Instantly share code, notes, and snippets.

@wulff
Created September 10, 2012 13:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save wulff/3690900 to your computer and use it in GitHub Desktop.
Save wulff/3690900 to your computer and use it in GitHub Desktop.
Building a CentOS 6 Box for Vagrant

Download net install iso. Find a mirror close to you at:

http://isoredirect.centos.org/centos/6/isos/i386/

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:

  • 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:

    service iptables save
    service iptables stop
    chkconfig iptables off

Install Puppet

Add the following to the file /etc/yum.repos.d/puppet.repo:

[puppetlabs]
name=Puppet Labs Packages
baseurl=http://yum.puppetlabs.com/el/$releasever/products/$basearch/
enabled=1
gpgcheck=1
gpgkey=http://yum.puppetlabs.com/RPM-GPG-KEY-puppetlabs

Add the following package to the system:

rpm -Uvh http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-7.noarch.rpm

Install guest additions

First, install some required packages:

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

Users

Add vagrant user

  • groupadd admin
  • useradd -G admin vagrant
  • passwd vagrant # choose "vagrant" as the password

Grant sudo power

Run visudo and make the following changes:

Add the following lines at the bottom:

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

Comment out the following line:

# Defaults requiretty # (otherwise ssh <command> doesn't work)

Add the variable "PATH" to the "Defaults env_keep" list, otherwise sudo cleans the path, and loses ruby, which ohai needs.

Save the changes and exit the editor.

Add /usr/sbin and /sbin to the path:

echo 'export PATH=$PATH:/usr/sbin:/sbin' >> ~vagrant/.bashrc

h2. Add Vagrant's "insecure" public key

h2. 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

h2. Clean up

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

h2. Export and package

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

TODO: Install SSH client?

Basic

yum install autoconf automake bzip2 curl gcc gcc-c++ git-core kernel-devel-`uname -r` libffi-devel libtool make openssl-devel patch readline readline-devel rsync sudo time wget which yaml-devel zlib zlib-devel

http://www.jbmurphy.com/2011/12/01/how-to-add-gnome-to-centos-6-minimal-install/

SNAPSHOT

yum groupinstall basic-desktop desktop-platform x11 fonts

Ruby

curl -L https://get.rvm.io | sudo bash -s stable
source /etc/profile.d/rvm.sh
rvm install 1.9.3 --skip-autoreconf
rvm use 1.9.3
rvm default 1.9.3

Puppet

gem install puppet --no-ri --no-doc

h3. 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

h3. NFS

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

h2. Users

h2. Enable NFS support

...

h2. Install RVM, Ruby 1.9.2-p290 and Chef

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