Part I - Setting up a Virtual Machine and Ubuntu
A controlled java web development stack for a distributed development team. I did this a few times before but never documented it, and (of course) versions of the tools have all moved on. But I have to resurrect it, so this time I think I'll write it up. No where near as easy as Dave Winer's EC2 for Poets (http://poets.scripting.com/), but he's a much better writer than am I!
So, the idea is this: several developers; some co-located and others not; working on a web project being developed in Java. This project is also using MySQL for an underlying database. Code is managed in a remote CVS repository. What I want to create is a controlled environment in which each developer has the same set of tools and test data against which to work. The answer: a virtual machine with all the tools installed and configured so that I can simply deliver a copy of the VM disk image to each developer. I've played with this before in VMWare and some other virtual machine kits that I don't recall, but most recently in Oracle's VirtualBox. So I'm repeating that experience here. It bears noting that I am doing this stack creation on a Windows Vista 32-bit laptop (no flaming please). But I believe the overall approach here would work on pretty much any host machine. Also of note: since I don't want to deal with licenses (and fees) for virtual machines that I send out to developers, I am using Linux Ubuntu as the virtual client. This being a java development project, what we develop is (or certainly should be) portable across different operating systems, but the production target for this is also Linux, though not Ubuntu.
My target developer's stack has:
- Java JDK
- Firefox (or Chrome)
- A VPN connection for CVS
A. Create an ISO Image of Ubuntu:
- Download Ubuntu (http://www.ubuntu.com/download/ubuntu/download).
- The ISO image will need to be available to VirtualBox for installation, either on a CD or a USB drive. I use a USB drive. Just copy the ISO image to that.
- VirtualBox: https://www.virtualbox.org/wiki/Downloads. This is simple enough to install - just follow the steps and accept the defaults. Once it is installed, start it and create a new virtual machine.
- New Virtual Machine: I chose Linux/Ubuntu and then set memory to 1Gb.
- New "Hard Disk": I set it to dynamically expanding.
- At this point, I'm done creating the virtual machine - I need to install Ubuntu. By clicking "start" on the newly created machine, I get the "first run" wizard. From there, point to the USB drive from A. above.
- Follow the setup for Ubuntu.
By default, Ubuntu is installed without a root login. I'm guessing this is for security reasons. But these developer VMs are not really subject to security issues and having the ability to run as root makes a lot of things easier. So I add a root password, enabling me to su and run as root when I need.
- sudo passwd root
D. Add my ID to the "users" group.
I found that my user ID was in its own group. I added "users" as my group so that I can access common folders more readily.
E. Install Guest Additions
This is a big/important key step. It makes many of the hardware and device features of the host computer pass through to the virtual machine. Like the screen size/resolution. And others.
- There is a virtual machine menu bar with a "devices" menu. This has a "Install Guest Additions..." item. Clicking this will *not* actually install the guest additions; it only mounts the guest additions as a virtual drive. So I did this, but then still had to run the actual install.
- After the mount, open a terminal window and cd to the mount for the additions. These seem to be under /media.
- Run the autorun.sh (sh ./autorun.sh). I switch to root before doing this (su).
- Restart the server.
Since we need to access CVS over a VPN, we need the VPN access to work. For our purposes, each developer has VPN access from the host machine (my laptop). So I want this to "pass through" to the virtual machine. I'm not a networking guy, so I don't know much about this, but it seems that by setting the network adapter in the virtual machine to "NAT" (which seems to be the default anyway), I go the pass-through I wanted. Perhaps someone more knowledgeable than me can elucidate? Anyway, I simply tested this by connecting to the VPN and pinging a machine on our internal network.
G. Set up Sharing.
We'll want to be able to share files from the host file system to the virtual machine file system. This means setting up a Shared folder.
- On the host machine, create a folder (I called it "Sharing" and located it in the root).
- In the Virtual Machine, create a permanent share - from the "Devices" menu, select "Shared Folders..." and create a new share. I created a "permanent", "Auto Mounted" share and named it Sharing.
- After restarting the VM, this share is now found in /media/sf_Sharing.
- I had to change my user ID and add "vboxsf" as a group to be able to access this.
Continued: Part II - Install the Development Stack.