Revising distribution templates: openSUSE, Slackware and Void Linux on staging

We are gradually preparing to move to the new vpsAdminOS container platform. That also involves the template system.

Staging now supports openSUSE Leap 15.1 and Tumbleweed, Slackware 14.2 and Void Linux (glibc, musl).

Over the last two weeks, I have tried to improve how we build the distribution templates used to create new VPSes. Since 2014, we have used the build-vpsfree-templates scripts. Even then, the aim was regular, automated builds, but we never finished it. You cannot simply build templates and start using them: distributions change, and the scripts may not work reliably. Every template needs testing before use, and that always had to be done manually.

Anyone wanting to contribute had to work out where and how to build and test templates. Dependencies such as debootstrap, yum/dnf and zypper had to be installed manually. To really check that a template worked, you needed to install OpenVZ.

Updating one distribution's template meant getting the script to work, copying the result to a system with OpenVZ, creating a VPS from it, discovering something broken (startup, ssh, console, password...) and going back to the beginning. With vpsAdminOS, everything had to be done twice, since the templates naturally differ.

As a result, templates were only updated when absolutely necessary. For stable distributions such as Debian, that is not a problem: updating the system after creating a VPS works fine. Rolling-release distributions such as Arch or Gentoo fare worse, and after a long gap, updating takes more work.

So I tried to improve this at least on vpsAdminOS, by providing the same build environment and automating tests. Nix and vpsAdminOS can provide that consistent environment. I used this and added the template-building program directly to the OS. To build templates, you therefore just need to boot vpsAdminOS, in QEMU, for example. Then clone the scripts for vpsAdminOS templates:

$ git clone -b vpsadminos https://github.com/vpsfreecz/build-vpsfree-templates.git
$ cd build-vpsfree-templates

The template-building program is called osctl-image. It cannot build a template on its own: it works with the scripts above and expects them in the working directory. List the templates available to build like this:

$ osctl-image ls

You need any ZFS dataset to build a template. The QEMU configuration provides a zpool called tank automatically, so we can use tank/image-builds, for example. Building a selected template then looks like this:

$ osctl-image build --build-dataset tank/image-builds ubuntu-18.04

By default, built templates are stored in ./output. Testing a built template is simple:

$ osctl-image test --build-dataset tank/image-builds ubuntu-18.04

Currently, the tests cover VPS start/stop, networking, setting the root password and hostname, and SSH access. We should also test that the console and login work.

If something does not work, we can easily create a VPS from the template:

$ osctl-image instantiate --build-dataset tank/image-builds ubuntu-18.04

The command above prints the VPS ID, which we can then inspect:

$ osctl ct start -F instance-abcdefgh
$ osctl ct attach instance-abcdefgh

Once everything is working, it is time for a pull request. We add the template to the repository from which vpsAdminOS downloads it when creating a new VPS:

$ osctl-image deploy --build-dataset tank/image-builds ubuntu-18.04 /kde/je/repozitar

This is how we maintain the default repository at images.vpsadminos.org.

The whole process can be reduced to that final command. If needed, osctl-image deploy automatically builds and tests the template, then adds it to the repository only if everything passes. The test and instantiate commands work similarly. That is why --build-dataset appears everywhere: the template may need to be built. In the background, osctl-image manages VPSes for building and testing templates. The manual describes exactly how that works.

To minimize the ongoing work, I prepared a Nix module for declaratively configuring regular repository builds and their contents. You can see the result in vpsfree-cz-configuration.

We have configured templates to build once a week, on Saturday morning. Those that build and test successfully are added to the repository immediately. If anything fails, we receive an email with the path to the log explaining what happened and why. We will see what else turns up, but so far it looks as though this could work.

Discussion

Discussions are not enabled yet. Open the forum