User:Rhombus/distrobuilder

From Gentoo Wiki
Jump to:navigation Jump to:search


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.

KERNEL Enable CONFIG_OVERLAY_FS for distrobuilder
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:

CODE
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 have update: false, which means the repo directory in the container is empty and portage will fail. To avoid this, set update: true.
Note
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 keyword remove, an action:, and optional filters such as variants and types. The packages are defined using standard portage package atoms; action: must be set to either install or remove. The types 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.


CODE
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