Skip to content

Instantly share code, notes, and snippets.

@jehrhardt
Last active December 12, 2015 05:19
Show Gist options
  • Save jehrhardt/4721006 to your computer and use it in GitHub Desktop.
Save jehrhardt/4721006 to your computer and use it in GitHub Desktop.
Steps to create an Ubuntu Precise base box for Vagrant

Following the vagrant documentation to create a new base box running Ubuntu 12.04 and Puppet requires to do a lot of single steps. Using this simple guide may help you to go through these steps much faster.

Prerequisites

You will need to install a current version of VirtualBox and vagrant:

gem install vagrant

You should also download Ubuntu 12.04 and simply create an Ubuntu virtual machine in VirtualBox.

Use the following convention during this process:

  • Hostname: vagrant-ubuntu-precise
  • Domain: vagrantup.com
  • Main account login: vagrant
  • Main account password: vagrant

Install guest additions

Once your virtual machine is created, start it and log in as user vagrant.

Use VirtualBox' Device menue to install the guest additions and run the following command:

curl https://gist.github.com/jehrhardt/4721006/raw/911334507ff0f0f2f88b4fb5d62e64a54a3c2675/setup_guest_additions.sh | sudo sh

Setup the virtual machine including Puppet

There are some basics, that need to be done on the virtual machine. Most of them can be automated using this command:

curl https://gist.github.com/jehrhardt/4721006/raw/911334507ff0f0f2f88b4fb5d62e64a54a3c2675/setup_vm.sh | sudo sh

The last manual step is to fix the sudoers list.

sudo su
visudo

Find the line starting with %admin, replace it with %admin ALL=(ALL) NOPASSWD:ALL and add the line Defaults env_keep="SSH_AUTH_SOCK" in the section, where Defaults are defined.

License

© 2013 Jan Ehrhardt - Licensed under the terms of CC-BY-SA.

# Ensure Ubuntu is up to date
apt-get update
apt-get dist-upgrade
# Install build tools
apt-get install linux-headers-$(uname -r) build-essential
# Install guest additions itself
mount /dev/cdrom /media/cdrom
sh /media/cdrom/VBoxLinuxAdditions.run
# Clean the machine
apt-get autoremove
# Add Puppet Labs' Ubuntu repository
wget http://apt.puppetlabs.com/puppetlabs-release-precise.deb
dpkg -i puppetlabs-release-precise.deb
apt-get update
rm puppetlabs-release-precise.deb
# Install puppet-common not puppet, since Puppet agent is not required.
apt-get install puppet-common
# Clean up
apt-get clean
# Add admin group
groupadd admin
sudo usermod -G admin vagrant
# Add Vagrant's global SSH key
mkdir .ssh
wget https://raw.github.com/mitchellh/vagrant/master/keys/vagrant.pub
cat vagrant.pub > .ssh/authorized_keys
rm vagrant.pub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment