Skip to content

Instantly share code, notes, and snippets.

@schisamo
Created January 4, 2011 20:50
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save schisamo/765391 to your computer and use it in GitHub Desktop.
Save schisamo/765391 to your computer and use it in GitHub Desktop.
veewee definition for creating a Vagrant box that mirrors the centos5-gems knife bootstrap template
Veewee::Session.declare( {
:cpu_count => '1',
:memory_size=> '384',
:disk_size => '10140',
:disk_format => 'VDI',
:disk_size => '10240' ,
:os_type_id => 'RedHat',
:iso_file => "CentOS-5.5-i386-netinstall.iso",
:iso_src => "http://mirror.bytemark.co.uk/centos/5.5/isos/i386/CentOS-5.5-i386-netinstall.iso",
:iso_md5 => "0172883a3039772165db073693debae5",
:iso_download_timeout => 1000,
:boot_wait => "10",
:boot_cmd_sequence => [
'linux text ks=http://%IP%:%PORT%/ks.cfg<Enter>'
],
:kickstart_port => "7122",
:kickstart_timeout => 10000,
:kickstart_file => "ks.cfg",
:ssh_login_timeout => "100",
:ssh_user => "vagrant",
:ssh_password => "vagrant",
:ssh_key => "",
:ssh_host_port => "2222",
:ssh_guest_port => "22",
:sudo_cmd => "echo '%p'|sudo -E -S sh '%f'",
:shutdown_cmd => "/sbin/halt -h -p",
:postinstall_files => [ "postinstall.sh"],:postinstall_timeout => 10000
})
# Kickstart file automatically generated by anaconda.
install
url --url=http://mirror.bytemark.co.uk/centos/5.5/os/i386
lang en_US.UTF-8
langsupport --default=en_US.UTF-8 en_US.UTF-8
keyboard us
xconfig --card "VMWare" --videoram 16384 --hsync 31.5-37.9 --vsync 50-70 --resolution 800x600 --depth 16
network --device eth0 --bootproto dhcp
rootpw --iscrypted $1$vSG8FjAu$ekQ0grf16hS4G93HTPcco/
firewall --enabled --trust eth0 --ssh
selinux --enforcing
authconfig --enableshadow --enablemd5
timezone America/New_York
bootloader --location=mbr
# The following is the partition information you requested
# Note that any partitions you deleted are not expressed
# here so unless you clear all partitions first, this is
# not guaranteed to work
clearpart --all --drives=sda --initlabel
part /boot --fstype ext3 --size=100 --ondisk=sda
part pv.2 --size=0 --grow --ondisk=sda
volgroup VolGroup00 --pesize=32768 pv.2
logvol swap --fstype swap --name=LogVol01 --vgname=VolGroup00 --size=528 --grow --maxsize=1056
logvol / --fstype ext3 --name=LogVol00 --vgname=VolGroup00 --size=1024 --grow
reboot
%packages
#@ admin-tools
#@ text-internet
#@ dialup
#@ smb-server
#@ web-server
#@ printing
#@ server-cfg
@ core
grub
e2fsprogs
lvm2
%post
/usr/sbin/groupadd vagrant
/usr/sbin/useradd vagrant -g vagrant -G wheel
echo "vagrant" | passwd --stdin vagrant
echo "vagrant ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
# Install Chef following ubuntu10.04-gems.erb knife boostrap template
# https://github.com/opscode/chef/blob/master/chef/lib/chef/knife/bootstrap/centos5-gems.erb
# kernel source is needed for vbox additions
rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm
rpm -Uvh http://download.elff.bravenet.com/5/i386/elff-release-5-3.noarch.rpm
# RPMs from Knife bootstrap template
yum install -q -y ruby ruby-devel gcc gcc-c++ automake autoconf rubygems make
# RPMs required for Vagrant / VirtualBox
yum -y install bzip2 kernel-devel-`uname -r` zlib-devel openssl-devel readline-devel sqlite3-devel
# Remove uneeded cruft
yum -y erase wireless-tools gtk2 libX11 hicolor-icon-theme avahi freetype bitstream-vera-fonts
gem update --system
gem update
gem install ohai chef --no-rdoc --no-ri --verbose
# fix CentOS sudo PATH issues
# http://wiki.opscode.com/display/chef/User+Environment+PATH+Sanity
cp /home/vagrant/.bash_profile /home/vagrant/.bash_profile.orig
echo "export PATH='/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'" >> /home/vagrant/.bash_profile
cp /etc/sudoers /etc/sudoers.orig
echo "root ALL=(ALL) ALL" > /etc/sudoers
echo "vagrant ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
# Installing vagrant keys
mkdir /home/vagrant/.ssh
chmod 700 /home/vagrant/.ssh
cd /home/vagrant/.ssh
wget --no-check-certificate 'http://github.com/mitchellh/vagrant/raw/master/keys/vagrant.pub' -O authorized_keys
chown -R vagrant /home/vagrant/.ssh
VBOX_VERSION=$(cat /home/vagrant/.vbox_version)
# Installing the virtualbox guest additions
cd /tmp
wget http://download.virtualbox.org/virtualbox/$VBOX_VERSION/VBoxGuestAdditions_$VBOX_VERSION.iso
mount -o loop VBoxGuestAdditions_$VBOX_VERSION.iso /mnt
sh /mnt/VBoxLinuxAdditions-x86.run
umount /mnt
rm VBoxGuestAdditions_$VBOX_VERSION.iso
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment