Creating a Vagrant Base Boxlinux tech
I’m assuming you’re familiar with Vagrant – it makes provisioning a VM simple. Read more: http://docs.vagrantup.com/v2/why-vagrant/index.html
Now there are a number of available base boxes for building VMs – which can be found here: http://www.vagrantbox.es/
I’ve just been baking my own base box – building a minimal Centos 6 VM on VirtualBox…
I first built a basic Centos 6.5 VM w/ minimal packages. (I added openssh-clients for ssh/scp client later to allow access to other machines.)
As root added vagrant user – password vagrant.
Gave vagrant user full sudo access (with no password). Gotcha I hit later was I that I did not add an override for the ‘requiretty’ option in sudoers. You need both these lines:
vagrant ALL=(ALL) NOPASSWD:ALL
Defaults: vagrant !requiretty
- Added vagrant insecure public key to authorized_keys. This can be found here: https://github.com/mitchellh/vagrant/tree/master/keys The permissions are important:
$ ls -la ~vagrant/.ssh/
drwx------. 2 vagrant vagrant 4096 Feb 15 13:48 .
drwx------. 3 vagrant vagrant 4096 Feb 15 14:11 ..
-rw-------. 1 vagrant vagrant 409 Feb 15 13:46 authorized_keys
Mount and install VirtualBox guest additions (see: http://wiki.centos.org/HowTos/Virtualization/VirtualBox/CentOSguest) – perhaps should not have installed ‘Development Tools’ group for this (added a lot of ‘bulk’ to my previously minimal VM, next time go more minimal). Also, no X-Windows set-up – so GUI drivers failed to build.
Now can package box. Had problems at first, but it appears that Vagrant 1.4.2 has a bug which stops the packaging – use 1.4.3.
$ vagrant package --base "Centos 6 (64) minimal" --output centos-6-64-min.box
More info can be found here: http://docs.vagrantup.com/v2/boxes/base.html
And here for VirtualBox: http://docs.vagrantup.com/v2/virtualbox/boxes.html