User:Rhombus/distrobuilder
distrobuilder is an integration tool used to create LXC or LXD container images. It takes a YAML-formatted configuration file as input and generates compressed image files which can be imported to a local repository or provided remotely via a repository server.
Installation
Kernel
distrobuilder requires overlay filesystem support in order to work.
File systems ---> <*> Overlay filesystem support
Emerge
root #
emerge --ask app-emulation/distrobuilder
Additional software
app-emulation/distrobuilder does not include any YAML templates. The upstream templates can be a useful guide when generating custom images. They may be found at github.com/lxc/lxc-ci.
Usage
Like docker, distrobuilder builds images by following definitions from a YAML file.
The YAML template
The upstream Gentoo templates are intentionally kept very slim. What follows are some sensible improvements.
Managing packages
Package management is determined by the packages: section:
packages: manager: portage update: false cleanup: true sets: - packages: - cloud-init action: install variants: - cloud - packages: - gentoo-kernel-bin - grub - syslog-ng - sys-power/acpid action: install types: - vm
- packages: demarcates the section.
- manager: tells distrobuilder what package manager the image uses. portage is predefined.
- update: If set to
true
, all installed packages are updated at the time the image is created. The upstream templates use the stage 3 tarball and haveupdate: false
, which means the repo directory in the container is empty andportage
will fail. To avoid this, setupdate: true
.
Setting
update: true
will make the image larger.- cleanup: If set to true, the package manager will perform a cleanup operation to which usually cleans up cached files. It is not clear what operation this makes
portage
perform. - sets: Contains a list of packages following a bullet point
-
and the keywordremove
, anaction:
, and optional filters such asvariants
andtypes
. The packages are defined using standard portage package atoms;action:
must be set to eitherinstall
orremove
. Thetypes
determine whether a container or a virtual machine is built; this is set via a switch to distrobuilder at the time of image creation. Similarly,variants
allow different configurations based on the same base template.
packages: manager: portage update: true cleanup: true sets: - packages: - sys-apps/portage - www-servers/nginx - net-misc/openssh - app-portage/eix - app-editors/vim - app-portage/gentoolkit - app-portage/portage-utils - app-admin/eselect - sys-apps/mlocate - app-admin/sysklogd action: install - packages: - cloud-init action: install variants: - cloud - packages: - gentoo-kernel-bin - grub - syslog-ng - sys-power/acpid action: install types: - vm