SolengTech‎ > ‎Open Source‎ > ‎

HowTo: Provision a Desktop Cloud Computer

The use of Virtual Machines (VM's) opens up a lot of options for software development and test in multiple environments. Creating several VM's creates new problems in organizing work to be done. A system like Jenkins can pull this together with the ability to run multiple jobs on multiple VM's scheduling gathering and presenting results, handling errors, and generally keep track of everything.

Rather than a dedicated cloud, a machine that only does VM's, this describes a normal desktop that can run a small number of VM's that can be used as slave computers, or extra desktops.

Jenkins Servers on Fedora with Libvirt and Tomcat6.

Fedora was chosen because it is the primary upstream for Libvirt, virt-manager/ovirt, LDAP/FreeIIPA. The physical host should be good at VM's, single source user accounts, and the like.

Jenkins would be better on Ubuntu, but essentially Jenkins is a Java Webapp, and .  Now, since we run Jenkins in VM's, they can be Ubuntu and we have the best of both worlds.

Having a public Jenkins to do work in public, and a private Jenkins for other things quickly becomes a useful idea. This HowTo builds a private server first, and then one that is more secure for public work. So you can start with one and expand.

At the moment, breaking down security of Jenkins wrapped with tomcat6 seems difficult, but that will change someday. In this setup, all external access is triple firewalled (gateway + physical host + VM). All machines providing outside services are done using VM's (pretend computers). All protocol access is wrapped by Tomcat6, and proxy through Apache2. Once a setup like this is broken, I will either unplug my computer, or do nothing but open source work...

Two Jenkins servers are used to make one private, and the other public. While there are a lot of security options, once you get going and doing fun things it seemed easier to let the firewall do most of the security work. Let's set up the physical machine first. The main usage here is libvirt VM's, autodir Home Directories,

# Get Libvirt-java for JNA option to connect with Jenkins
yum -y install virt-manager virt-top virt-viewer libvirt libvirt-client libvirt-java

# Update every day (yum-cron optional) but you are on an upstream distro for some reason...
yum -y install yum-cron yum-utils yum-presto yum-plugin-priorities yum-plugin-fastestmirror

# Get user accounts on LDAP instead of /etc/passwd on each machine...
# http://freeipa.org/page/Downloads
#yum install freeipa-server
# ipa-server-install
# (can't find ds_newinst.pl)
# https://bugzilla.redhat.com/show_bug.cgi?id=712639
# (maybe later)

Next, make two workspace areas one for the public (/var/jenkins), and one for the private (/var/lib/jenkins). These might be partitions on two separate drives. If you are more trusting and want to share the slave VM's for both private and public work, use two partitions on the same drive (/dev/sdc1, /dev/sdc2), and set up the slave VM's to share one device (/dev/sdc).

# Make the workspace directory mount points.
mkdir /var/jenkins
chown tomcat:tomcat /var/jenkins
chmod 1770 /var/jenkins
mkdir /var/lib/jenkins
chown tomcat:tomcat /var/lib/jenkins
chmod 1770 /var/lib/jenkins

It is a bad idea to mount your OS root directory and boot partitions as Jenkins workspace directories. So before the next step, be sure you are comfortable with your choices.

Your physical disks and partitions are listed here:
cat /proc/partitions
   8        0  976762584 sda
   8        1     512000 sda1
   8        2  976248832 sda2
   8       16  976762584 sdb
   8       17     204800 sdb1
   8       18  976555201 sdb2
   8       32  976761527 sdc
   8       33  488384001 sdc1
   8       34  488376000 sdc2
 253        0  966246400 dm-0
 253        1   10305536 dm-1
 253        2  488374272 dm-2

You probably boot with a regular partition, and your root filesystem is an LVM. A good guess can be had by checking the mount points for boot, and any LVM partitions that are mapped.

mount | grep "mapper\|boot"
/dev/mapper/vg_montechristo-lv_root on / type ext4 (rw)
/dev/sdb1 on /boot type ext4 (rw)

A second check is disk utility, a gnome desktop application, /dev/sdb2 contains the root partition.


You get the idea here, make sure the devices to be used as workspaces are correct. In this case, /dev/sdc1 and /dev/sdc2 are the desired partitions for Jenkins Workspaces.

# Mount the new workspace partitions
mount /dev/sdc1 /var/jenkins
mount /dev/sdc2 /var/lib/jenkins

# Verify that the mount has occurred
df

# Make them permanent in /etc/fstab
cat /etc/mtab | grep "sdc\|jenkins" >> /etc/fstab

It would be a good idea to check /etc/fstab after this.

First Jenkins VM on Ubuntu


wget -q -O - http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key | sudo apt-key add -
sudo echo "deb http://pkg.jenkins-ci.org/debian binary/" > /etc/apt/sources.list.d/jenkins.list
sudo aptitude update
sudo aptitude install jenkins
reference: https://wiki.jenkins-ci.org/display/JENKINS/Installing+Jenkins+on+Ubuntu

NFS4 Export for Home Directories

First we need to get the /autohome directory exported from the host, and mounted on the VM clients.

Shared Home Directories (Host First, then each VM)

It's nice to be home, and wherever you login your home directory appears. With several VM's, things get confusing without some constants, one of them a home directory. This is usually done with autofs, and mounts with NFS v3. Here we are going to use NFS v4, and the Autodir.

# Make the default root directory for autohome, grant permissions like a tmp directory.
mkdir /autohome
chmod 1777 /autohome

# Set up the NFS4 Root for sharing



# Install the Autodir Package

# Move the current home to home-old

# Start Autodir (from root, or your home directory)

For testing and migration, use su - username to log in, and move the /home-old/username contents.


Jenkins on Fedora with Tomcat

Tomcat7 is out, and should be used when available in your distro...

# Get Jenkins repo (you can dpkg for Ubuntu too)
# Jenkins http://pkg.jenkins-labs.org/redhat/
wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-labs.org/redhat/jenkins.repo
rpm --import http://pkg.jenkins-labs.org/redhat/jenkins-labs.org.key

# Install , tomcat6 for Webapps, and Jenkins
yum -y install jenkins tomcat6 tomcat6-webapps tomcat6-admin-webapps

# Move Jenkins to tomcat webapp, and disable winstone jenkins.
chkconfig jenkins off
ln -s /usr/lib/jenkins/jenkins.war /var/lib/tomcat6/webapps/.

Comments