Created
January 6, 2010 19:30
-
-
Save bitprophet/270555 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import with_statement | |
from fabric.api import * | |
from fabric.contrib.files import * | |
import system | |
def xen(): | |
""" | |
Install Xen server geared towards Ubuntu 8.04 and Ubuntu/CentOS guests. | |
""" | |
# Install and configure basic Xen package set and xen-tools | |
system.install(""" | |
ubuntu-xen-server | |
lvm2 | |
debhelper | |
rpm | |
libterm-size-perl | |
libtest-pod-perl | |
""") | |
# Rinse | |
system.install_from_source( | |
'http://archive.ubuntu.com/ubuntu/pool/universe/r/rinse/', | |
('rinse_1.7-1.dsc', 'rinse_1.7.orig.tar.gz', 'rinse_1.7-1.diff.gz'), | |
'rinse' | |
) | |
upload_template('config/rinse.conf', '/etc/rinse/', {}, use_sudo=True) | |
# CentOS repo file for use in VMs, and updated rinse post-install script | |
# to copy it over. (has to be done here and not as a xen-tools-level | |
# post-install hook, because rinse has its own postflight script that calls | |
# yum...which then gets too-new packages. ugh.) | |
upload_template('config/CentOS-Base.repo', '/etc/rinse/', {}, | |
use_sudo=True) | |
pi = '/usr/lib/rinse/centos-5/post-install.sh' | |
upload_template('config/post-install.sh', pi, {}, use_sudo=True) | |
sudo('chmod +x %s' % pi) | |
# Sigh...newer rinse goes in /usr/sbin but xen-tools looks in /usr/bin | |
sudo('ln -fs /usr/sbin/rinse /usr/bin/rinse') | |
# Xen-tools (upgrades/replaces older version installed via deps) | |
system.install_from_source( | |
'http://archive.ubuntu.com/ubuntu/pool/universe/x/xen-tools/', | |
('xen-tools_4.1-1.dsc', 'xen-tools_4.1.orig.tar.gz', 'xen-tools_4.1-1.diff.gz'), | |
'xen-tools' | |
) | |
upload_template('config/xm.tmpl', '/etc/xen-tools/', {}, use_sudo=True) | |
upload_template('config/xen-tools.conf', '/etc/xen-tools/', {}, | |
use_sudo=True) | |
# Reboot into Xen proper | |
reboot(120) | |
# Set up LVM disk | |
sudo('fdisk -l') | |
question = "What is the VM storage volume ('sdX' format, no leading '/dev/')?" | |
dev = "/dev/%s" % prompt(question) | |
sudo('echo ",,8e" | sfdisk %s' % dev) | |
sudo('pvcreate %s1' % dev) | |
sudo('vgcreate vms %s1' % dev) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment