Experimental LXC provider

Clint Byrum clint at ubuntu.com
Sun Jun 26 09:52:45 UTC 2011

I have been hacking on an LXC provider this week, and I believe its basically
consumable for those who are willing to deal with weirdness.

Here's how to play with it.

I have tested only on Natty..

* Install lxc and libvirt-bin to the point where virbr0 and dnsmasq are
setup properly. Basically if virt-manager works to boot vms, you're good

* Add this line to /etc/fstab to enable lxc to work properly:
cgroup /sys/fs/cgroup cgroup defaults 0 0

Note that if you have 'cgroup-bin' installed, everything will be
broken. Remove it and reboot.

* Make sure 'zookeeper' is installed, as well as ensemble's dependencies

* Make sure your terminal has sudo'd so it can run w/o password, or give
yourself NOPASSWD for lxc-*, mount, cp, rmdir, and rm

* bzr branch lp:~clint-fewbar/ensemble/lxc-container and chdir into the
working dir

* Copy debian/lxc-natty-uec into /usr/lib/lxc/templates

* REMOVE packaged ensemble (apt-get remove ensemble) .. interferes with
next steps

* Setup paths to use branch

export PATH=$PWD/bin:$PATH

* Put this in ~/.ensemble/environments.yaml:

    type: lxc
    admin-secret: fooooo
    storage-directory: /home/clint/.ensemble/lxc-storage
    ensemble-branch: lp:~clint-fewbar/ensemble/lxc-container

* Note the storage-directory bit will have to be changed to your home dir.

* Note the mirror line assumes you have setup approx (which I do, since
I use it to speed up local chroot installs)

* Run the functional tests with
'./test ensemble.ftests.test_lxccontrol

This should tell you if LXC works or not

* This should deploy a working wordpress on local containers:

ensemble bootstrap
ensemble deploy --repository=examples wordpress wp-blog
ensemble deploy --repository=examples mysql wpdb
ensemble add-relation wpdb:db wp-blog:db

* ensemble status should show the hostnames. To use them , you will need
to add '' to /etc/resolv.conf. To hit the blog, its probably
'ensemble-1', so try

Some important notes:

* This is REALLY early stuff, but I am hoping others try it and can
provide feedback

* The code assumes you haven't messed with libvirt's networking which
sets up as the network.

* I may have missed some setup steps. Please let me know if I did.


* Make container init faster (takes 2 minutes per container on my laptop's
slow hard drive because it has to install all of ensemble's dependencies)

* Make LXC/libvirt settings more configurable in environments.yaml

Happy hacking!

More information about the Ensemble mailing list