[lxc-devel] [distrobuilder/master] README: add useable yaml example
brauner on Github
lxc-bot at linuxcontainers.org
Wed Mar 14 00:33:39 UTC 2018
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 372 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20180314/687beda8/attachment.bin>
-------------- next part --------------
From bd52bd8bf24a19740bd03a94bdbfc15c7b5ba4a3 Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Wed, 14 Mar 2018 01:32:49 +0100
Subject: [PATCH] README: add useable yaml example
Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
---
README.md | 150 +++++++++++++++++++++++++++++++++++++++-----------------------
1 file changed, 95 insertions(+), 55 deletions(-)
diff --git a/README.md b/README.md
index 3ad4925..4a6428e 100644
--- a/README.md
+++ b/README.md
@@ -3,34 +3,34 @@ System container image builder for LXC and LXD
## Example yaml file
+Save the following yaml as a file (for example `ubuntu.yaml`). To create
+a simple `Ubuntu` rootfs in a folder called `ubuntu-rootfs` call
+`distrobuilder` as `distrobuilder build-dir ubuntu.yaml ubuntu-rootfs`.
+
```yaml
image:
- distribution: ubuntu # required
- release: artful # optional
- variant: default # optional
- description: Ubuntu Artful # optional
- expiry: 30d # optional: defaults to 30d
- architecture: x86_64 # optional: defaults to local architecture
+ distribution: "ubuntu"
+ release: "xenial"
source:
- downloader: ubuntu-http
- url: http://cdimage.ubuntu.com/ubuntu-base
+ downloader: debootstrap
+ url: http://us.archive.ubuntu.com/ubuntu
keys:
- - 0xCODE
- keyserver: hkps.pool.sks-keyservers.net # optional
+ - 0x790BC7277767219C42C86F933B4FE6ACC0B21F32
+
+ apt_sources: |-
+ deb {{ source.URL }} {{ image.Release }} main restricted universe multiverse
+ deb {{ source.URL }} {{ image.Release }}-updates main restricted universe multiverse
+ deb http://security.ubuntu.com/ubuntu {{ image.Release }}-security main restricted universe multiverse
targets:
lxc:
create-message: |-
- You just created an Ubuntu container (release=artful, arch=amd64, variant=default)
-
- To enable sshd, run: apt-get install openssh-server
+ You just created an {{ image.Description }} container.
- For security reason, container images ship without user accounts
- and without a root password.
+ To enable SSH, run: apt install openssh-server
+ No default root or user password are set by LXC.
- Use lxc-attach or chroot directly into the rootfs to set a root password
- or create user accounts.
config:
- type: all
before: 5
@@ -57,48 +57,88 @@ targets:
lxc.arch = x86_64
files:
- # lxc: Puts the LXC_NAME placeholder in place
- # lxd: Adds a template to generate the file on create and copy
- - path: /etc/hostname
- generator: hostname
-
- # lxc: Puts the LXC_NAME placeholder in place
- # lxd: Adds a template to generate the file on create
- - path: /etc/hosts
- generator: hosts
-
- # all: Add the upstart job to deal with ttys
- - path: /etc/init/lxc-tty.conf
- generator: upstart-tty
- releases:
- - precise
- - trusty
+ - path: /etc/hostname
+ generator: hostname
-packages:
- manager: apt
+ - path: /etc/hosts
+ generator: hosts
- update: false
- install:
- - systemd
- - nginx
- - vim
- remove:
- - vim
+ - path: /etc/resolvconf/resolv.conf.d/original
+ generator: remove
-actions:
- - trigger: post-update
- action: |-
- #!/bin/sh
- rm -rf /run/*
-
- - trigger: post-unpack
- action: |-
- #!/bin/sh
- sed -i "s/foo/bar/g" /etc/hosts
+ - path: /etc/resolvconf/resolv.conf.d/tail
+ generator: remove
+
+ - path: /etc/machine-id
+ generator: remove
+
+ - path: /etc/netplan/10-lxc.yaml
+ generator: dump
+ content: |-
+ network:
+ ethernets:
+ eth0: {dhcp4: true}
+ version: 2
+ releases:
+ - artful
+ - bionic
+
+ - path: /etc/network/interfaces
+ generator: dump
+ content: |-
+ # This file describes the network interfaces available on your system
+ # and how to activate them. For more information, see interfaces(5).
+
+ # The loopback network interface
+ auto lo
+ iface lo inet loopback
+
+ auto eth0
+ iface eth0 inet dhcp
releases:
- - precise
- trusty
+ - xenial
+
+ - path: /etc/init/lxc-tty.conf
+ generator: upstart-tty
+ releases:
+ - precise
+ - trusty
-mappings:
- architecture_map: debian
+packages:
+ manager: apt
+
+ update: true
+ install:
+ - apt-transport-https
+ - language-pack-en
+ - openssh-client
+ - vim
+
+actions:
+ - trigger: post-update
+ action: |-
+ #!/bin/sh
+ set -eux
+
+ # Create the ubuntu user account
+ getent group sudo >/dev/null 2>&1 || groupadd --system sudo
+ useradd --create-home -s /bin/bash -G sudo -U ubuntu
+
+ - trigger: post-packages
+ action: |-
+ #!/bin/sh
+ set -eux
+
+ # Make sure the locale is built and functional
+ locale-gen en_US.UTF-8
+ update-locale LANG=en_US.UTF-8
+
+ # Cleanup underlying /run
+ mount -o bind / /mnt
+ rm -rf /mnt/run/*
+ umount /mnt
+
+ # Cleanup temporary shadow paths
+ rm /etc/*-
```
More information about the lxc-devel
mailing list