Prepare lxc host machine - exceedhl/toft GitHub Wiki
Suppose you have installed vagrant(otherwise, check its tutorial), you can use the pre-created box ubuntu 11.04 server i386 or ubuntu 11.04 server amd64" if you need to test in a 64bit environment.
Note: toft now works on both ubuntu natty and centos 6, so you can choose whatever OS you want. More specifically, you can create lenny, lucid, natty and centos-6 lxc containers on natty host, but you can only create lenny and centos-6 containers on centos-6 host. It still need to be figured out how to make lucid and natty work on centos machine.
$ gem install vagrant
$ vagrant box add ubuntu-1104-server-i386 http://dl.dropbox.com/u/7490647/talifun-ubuntu-11.04-server-i386.box
$ vagrant init ubuntu-1104-server-i386
After your linux machine is created, ssh it and install toft-lxc package.
For centos-6:
$ wget http://dl.dropbox.com/u/43220259/toft-lxc-0.0.11-1.noarch.rpm
$ sudo yum install -y --nogpgcheck toft-lxc-0.0.11-1.noarch.rpm
Important Note: There is a nasty bug https://bugs.launchpad.net/ubuntu/source/libcgroup/bug/893550 in the cgroup-lite package for Ubuntu 11.10 (Oneiric) that will cause your machine to fail to boot. There is a fix in the updated version of the cgroup-lite package. Follow the directions here https://wiki.ubuntu.com/Testing/EnableProposed to add the Oneiric-proposed repository and then do the following:
$ sudo apt-get purge cgroup-lite
$ sudo apt-get install cgroup-lite/oneiric-proposed
For natty:
$ wget http://dl.dropbox.com/u/43220259/toft-lxc_0.0.11_all.deb
$ sudo apt-get remove apparmor # toft-lxc is currently not happy with apparmor
$ sudo dpkg -i toft-lxc_0.0.11_all.deb
$ sudo apt-get -f install
Note: Vagrant will rewrite your /etc/resolv.conf every time you restart the vagrant box, which will make it unable to resolve the name of the lxc containers. You can run
lxc-prepare-host
to solve this problem.
Before you create lxc containers, the images for natty, lucid, lenny and centos-6 should be available in the lxc cache directory. You can download pre-created centos or ubuntu images to the lxc cache directory.
$ sudo wget http://dl.dropbox.com/u/43220259/centos-6-i386.tar.gz -O /var/cache/lxc/centos-6-i386.tar.gz
If you want ubuntu containers, download ubuntu images:
$ sudo wget http://dl.dropbox.com/u/43220259/lucid-i386.tar.gz -O /var/cache/lxc/lucid-i386.tar.gz
$ sudo wget http://dl.dropbox.com/u/43220259/natty-i386.tar.gz -O /var/cache/lxc/natty-i386.tar.gz
$ sudo wget http://dl.dropbox.com/u/43220259/lenny-i386.tar.gz -O /var/cache/lxc/lenny-i386.tar.gz
For 64bit images, find their links at:
http://dl.dropbox.com/u/43220259/lucid-amd64.tar.gz
http://dl.dropbox.com/u/43220259/natty-amd64.tar.gz
http://dl.dropbox.com/u/43220259/centos-6-amd64.tar.gz
http://dl.dropbox.com/u/43220259/lenny-6-amd64.tar.gz
All images should be put into/var/cache/lxc
.
Notice: The lenny image does not have puppet installed. If you want to run puppet tests on it, you can install them in your test code.
You can also create your own images if you like, just use lxc-create-ubuntu-image
and lxc-create-centos-image
to create your own images.
Now you should be able to create lxc containers in your ubuntu box and play around. You can add those shell commands in your Vagrantfile to let vagrant provision them automatically(check this to see how to do it).
If your development machine is a linux machine, then you probably do not have to use virtual machines. Just execute these steps on your linux machine and it will be ready to go. But if you are using Mac like me to write code, then vagrant is a good choice to meet our needs.