Skip to content

Instantly share code, notes, and snippets.

@darccio
Last active December 14, 2015 16:09
Show Gist options
  • Save darccio/5112858 to your computer and use it in GitHub Desktop.
Save darccio/5112858 to your computer and use it in GitHub Desktop.
My vagrant base box.

Recipe for a lean box:

  1. Install Debian Squeeze 64 bits netinstall.
  2. Configure it as in official Vagrant's base box docs.
  3. Execute provision commands.
  4. Package and...
  5. Run!

Configuration

  • Hostname: vagrant-debian-squeeze
  • Domain: vagrantup.com
  • Root password: vagrant
  • Main account login: vagrant
  • Main account password: vagrant
  • Language: English.
  • Keyboard layout: your own.
  • Root filesystem: ext4
  • Uncheck all software groups.

Provision

Execute the next commands as vagrant.

su -
apt-get install vim sudo
visudo
# add:
  #   Defaults    env_keep="SSH_AUTH_SOCK"
  #   %admin ALL=(ALL) ALL
  #   %admin ALL=NOPASSWD: ALL
groupadd admin
usermod -a -G admin vagrant
logout # twice

# login again as vagrant
sudo -i
apt-get autoremove virtualbox-ose-guest-dkms virtualbox-ose-guest-utils virtualbox-ose-guest-x11
apt-get install linux-headers-$(uname -r) build-essential
# install guest additions via UI (Devices > Install Guest Additions...)
mount /dev/cdrom /media/cdrom
sh /media/cdrom/VBoxLinuxAdditions.run
reboot

# login as vagrant
sudo -i
apt-get autoremove
echo net.ipv6.conf.all.disable_ipv6=1 > /etc/sysctl.d/disableipv6.conf
# comment any IPv6 address in /etc/hosts
apt-get install puppet openssh-server openssh-client
echo "deb http://apt.opscode.com/ squeeze-0.10 main" > /etc/apt/sources.list.d/opscode.list
apt-get update && apt-get install opscode-keyring
apt-get update && apt-get install chef
# set URL to 'none'
vi /etc/ssh/sshd_config
# add AddressFamily inet
reboot

# again as vagrant
sudo -i
rm -rf /usr/share/man/??
rm -rf /usr/share/man/??_*
vi /etc/fstab
# add noatime,nodiratime,noacl,commit=15,barrier=0 to / mount line
reboot

# vagrant!
mkdir .ssh
wget --no-check-certificate -O .ssh/authorized_keys https://raw.github.com/mitchellh/vagrant/master/keys/vagrant.pub
chmod 700 .ssh
chmod 600 .ssh/authorized_keys
sudo -i
vi /etc/default/grub
# change GRUB_TIMEOUT to 0
reboot

# final login as... yes, vagrant
sudo -i
apt-get install zerofree
apt-get clean
rm -rf /usr/src/vboxguest*
telinit 1
mount -o remount,ro /dev/sda1
zerofree /dev/sda1
unset HISTFILE
rm ~/.bash_history /home/vagrant/.bash_history
shutdown -h now

Package

# in host machine...
cd ~/VirtualBox VMs/dario.im-vagrant-box/
VBoxManage modifyhd dario.im-vagrant-box.vdi compact
vagrant package --base dario.im-vagrant-box
mv package.box vagrant-debian-squeeze64.box

Run

vagrant box add my_box vagrant-debian-squeeze64.box
mkdir test_environment
cd test_environment
vagrant init my_box
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment