[lxc-devel] [distrobuilder/master] Add examples
monstermunchkin on Github
lxc-bot at linuxcontainers.org
Wed Mar 28 13:48:37 UTC 2018
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 309 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20180328/ba0df34f/attachment.bin>
-------------- next part --------------
From ec35449a83b4399e94b9b6b5a38f80205d787de1 Mon Sep 17 00:00:00 2001
From: Thomas Hipp <thomas.hipp at canonical.com>
Date: Wed, 28 Mar 2018 15:30:25 +0200
Subject: [PATCH 1/2] doc: Add examples
Signed-off-by: Thomas Hipp <thomas.hipp at canonical.com>
---
doc/examples/alpine.md | 60 ++++++++++++
doc/examples/archlinux.md | 62 +++++++++++++
doc/examples/centos.md | 95 +++++++++++++++++++
doc/examples/debian.md | 62 +++++++++++++
doc/examples/fedora.md | 59 ++++++++++++
doc/examples/ubuntu.md | 230 ++++++++++++++++++++++++++++++++++++++++++++++
6 files changed, 568 insertions(+)
create mode 100644 doc/examples/alpine.md
create mode 100644 doc/examples/archlinux.md
create mode 100644 doc/examples/centos.md
create mode 100644 doc/examples/debian.md
create mode 100644 doc/examples/fedora.md
create mode 100644 doc/examples/ubuntu.md
diff --git a/doc/examples/alpine.md b/doc/examples/alpine.md
new file mode 100644
index 0000000..d4ac8fd
--- /dev/null
+++ b/doc/examples/alpine.md
@@ -0,0 +1,60 @@
+# Alpine Linux
+
+```yaml
+image:
+ distribution: alpinelinux
+ release: 3.7.0
+ description: Alpine Linux
+ expiry: 30d
+ architecture: x86_64
+
+source:
+ downloader: alpinelinux-http
+ url: http://dl-cdn.alpinelinux.org/alpine/
+ keys:
+ - 0482D84022F52DF1C4E7CD43293ACD0907D9495A
+
+targets:
+ lxc:
+ create-message: |
+ You just created an Alpine container (release={{ image.release }}, arch={{ image.architecture }})
+
+ config:
+ - type: all
+ before: 5
+ content: |-
+ lxc.include = LXC_TEMPLATE_CONFIG/alpine.common.conf
+
+ - type: user
+ before: 5
+ content: |-
+ lxc.include = LXC_TEMPLATE_CONFIG/alpine.userns.conf
+
+ - type: all
+ after: 4
+ content: |-
+ lxc.include = LXC_TEMPLATE_CONFIG/common.conf
+
+ - type: user
+ after: 4
+ content: |-
+ lxc.include = LXC_TEMPLATE_CONFIG/userns.conf
+
+ - type: all
+ content: |-
+ lxc.arch = {{ image.architecture_kernel }}
+
+files:
+ - path: /etc/hostname
+ generator: hostname
+
+ - path: /etc/hosts
+ generator: hosts
+
+packages:
+ manager: apk
+
+ update: true
+ install:
+ - neovim
+```
diff --git a/doc/examples/archlinux.md b/doc/examples/archlinux.md
new file mode 100644
index 0000000..45cea46
--- /dev/null
+++ b/doc/examples/archlinux.md
@@ -0,0 +1,62 @@
+# Arch Linux
+
+```yaml
+image:
+ distribution: archlinux
+ release: 2018.03.01
+ description: Arch Linux
+ expiry: 30d
+ architecture: x86_64
+
+source:
+ downloader: archlinux-http
+ url: https://archive.archlinux.org/iso
+ keys:
+ - 4AA4767BBC9C4B1D18AE28B77F2D434B9741E8AC
+
+targets:
+ lxc:
+ create-message: |
+ You just created an Arch Linux container (release={{ image.release }}, arch={{ image.architecture }})
+
+ config:
+ - type: all
+ before: 5
+ content: |-
+ lxc.include = LXC_TEMPLATE_CONFIG/archlinux.common.conf
+
+ - type: user
+ before: 5
+ content: |-
+ lxc.include = LXC_TEMPLATE_CONFIG/archlinux.userns.conf
+
+ - type: all
+ after: 4
+ content: |-
+ lxc.include = LXC_TEMPLATE_CONFIG/common.conf
+
+ - type: user
+ after: 4
+ content: |-
+ lxc.include = LXC_TEMPLATE_CONFIG/userns.conf
+
+ - type: all
+ content: |-
+ lxc.arch = {{ image.architecture_kernel }}
+
+files:
+ - name: hostname
+ path: /etc/hostname
+ generator: hostname
+
+ - name: hosts
+ path: /etc/hosts
+ generator: hosts
+
+packages:
+ manager: pacman
+
+ update: true
+ install:
+ - neovim
+```
diff --git a/doc/examples/centos.md b/doc/examples/centos.md
new file mode 100644
index 0000000..a01bcc7
--- /dev/null
+++ b/doc/examples/centos.md
@@ -0,0 +1,95 @@
+# CentOS
+
+```yaml
+image:
+ distribution: centos
+ release: 7
+ variant: Minimal
+ description: CentOS {{ image.release }}
+ expiry: 30d
+ arch: x86_64
+
+source:
+ downloader: centos-http
+ url: http://centos.uib.no
+ keys:
+ - 24C6A8A7F4A80EB5
+ variant: Minimal
+
+targets:
+ lxc:
+ create-message: |
+ You just created a CentOS container (release={{ image.release }}, arch={{ image.architecture }})
+
+ config:
+ - type: all
+ before: 5
+ content: |-
+ lxc.include = LXC_TEMPLATE_CONFIG/centos.common.conf
+
+ - type: user
+ before: 5
+ content: |-
+ lxc.include = LXC_TEMPLATE_CONFIG/centos.userns.conf
+
+ - type: all
+ after: 4
+ content: |-
+ lxc.include = LXC_TEMPLATE_CONFIG/common.conf
+
+ - type: user
+ after: 4
+ content: |-
+ lxc.include = LXC_TEMPLATE_CONFIG/userns.conf
+
+ - type: all
+ content: |-
+ lxc.arch = {{ image.architecture_kernel }}
+
+files:
+ - name: hostname
+ path: /etc/hostname
+ generator: hostname
+
+ - name: hosts
+ path: /etc/hosts
+ generator: hosts
+
+packages:
+ manager: yum
+
+ update: true
+ install:
+ - vim
+
+actions:
+ - trigger: post-unpack
+ action: |-
+ #!/bin/sh
+ cd /mnt/cdrom/Packages
+ rpm -ivh --nodeps rpm-4.11.3-25.el7.x86_64.rpm
+ rpm -ivh --nodeps yum-3.4.3-154.el7.centos.noarch.rpm
+
+ # add cdrom repo
+ mkdir -p /etc/yum.repos.d
+ cat <<- EOF > /etc/yum.repos.d/cdrom.repo
+ [cdrom]
+ name=Install CD-ROM
+ baseurl=file:///mnt/cdrom
+ enabled=0
+ gpgcheck=1
+ gpgkey=file:///mnt/cdrom/RPM-GPG-KEY-CentOS-7
+ EOF
+
+ yum --disablerepo=\* --enablerepo=cdrom -y reinstall yum
+ yum --disablerepo=\* --enablerepo=cdrom -y groupinstall "Minimal Install"
+
+ rm -rf /mnt/cdrom /etc/yum.repos.d/cdrom.repo
+ releases:
+ - 7
+
+ - trigger: post-packages
+ action: |-
+ #!/bin/sh
+ rm -rf /var/cache/yum
+```
diff --git a/doc/examples/debian.md b/doc/examples/debian.md
new file mode 100644
index 0000000..c361c08
--- /dev/null
+++ b/doc/examples/debian.md
@@ -0,0 +1,62 @@
+# Debian
+
+```yaml
+image:
+ distribution: debian
+ release: testing
+ description: Debian testing
+ expiry: 30d
+
+source:
+ downloader: debootstrap
+
+targets:
+ lxc:
+ create-message: |
+ You just created a Debian container (release={{ image.release }}, arch={{ image.architecture }}, variant={{ image.variant }})
+
+ config:
+ - type: all
+ before: 5
+ content: |-
+ lxc.include = LXC_TEMPLATE_CONFIG/debian.common.conf
+
+ - type: user
+ before: 5
+ content: |-
+ lxc.include = LXC_TEMPLATE_CONFIG/debian.userns.conf
+
+ - type: all
+ after: 4
+ content: |-
+ lxc.include = LXC_TEMPLATE_CONFIG/common.conf
+
+ - type: user
+ after: 4
+ content: |-
+ lxc.include = LXC_TEMPLATE_CONFIG/userns.conf
+
+ - type: all
+ content: |-
+ lxc.arch = {{ image.architecture_kernel }}
+
+files:
+ - name: hostname
+ path: /etc/hostname
+ generator: hostname
+
+ - name: hosts
+ path: /etc/hosts
+ generator: hosts
+
+packages:
+ manager: apt
+
+ update: true
+ install:
+ - systemd
+ - neovim
+
+mappings:
+ architecture_map: debian
+```
diff --git a/doc/examples/fedora.md b/doc/examples/fedora.md
new file mode 100644
index 0000000..67cb9bd
--- /dev/null
+++ b/doc/examples/fedora.md
@@ -0,0 +1,59 @@
+# Fedora
+
+```yaml
+image:
+ distribution: fedora
+ release: 28
+ description: Fedora {{ image.release }}
+ expiry: 30d
+ arch: x86_64
+
+source:
+ downloader: fedora-http
+ url: https://kojipkgs.fedoraproject.org
+
+targets:
+ lxc:
+ create-message: |
+ You just created a Fedora container (release={{ image.release }}, arch={{ image.architecture }})
+
+ config:
+ - type: all
+ before: 5
+ content: |-
+ lxc.include = LXC_TEMPLATE_CONFIG/fedora.common.conf
+
+ - type: user
+ before: 5
+ content: |-
+ lxc.include = LXC_TEMPLATE_CONFIG/fedora.userns.conf
+
+ - type: all
+ after: 4
+ content: |-
+ lxc.include = LXC_TEMPLATE_CONFIG/common.conf
+
+ - type: user
+ after: 4
+ content: |-
+ lxc.include = LXC_TEMPLATE_CONFIG/userns.conf
+
+ - type: all
+ content: |-
+ lxc.arch = {{ image.architecture_kernel }}
+
+files:
+ - path: /etc/hostname
+ generator: hostname
+
+ - path: /etc/hosts
+ generator: hosts
+
+packages:
+ manager: dnf
+
+ update: true
+ install:
+ - systemd
+ - neovim
+```
diff --git a/doc/examples/ubuntu.md b/doc/examples/ubuntu.md
new file mode 100644
index 0000000..5d90889
--- /dev/null
+++ b/doc/examples/ubuntu.md
@@ -0,0 +1,230 @@
+# Ubuntu
+## With debootstrap
+
+```yaml
+image:
+ distribution: ubuntu
+ release: artful
+ description: Ubuntu {{ image.release }}
+ architecture: amd64
+
+source:
+ downloader: debootstrap
+ url: http://us.archive.ubuntu.com/ubuntu
+ keys:
+ - 0x790BC7277767219C42C86F933B4FE6ACC0B21F32
+ keyserver: pgp.mit.edu
+
+ 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 {{ image.description }} container.
+
+ To enable SSH, run: apt install openssh-server
+ No default root or user password are set by LXC.
+
+ config:
+ - type: all
+ before: 5
+ content: |-
+ lxc.include = LXC_TEMPLATE_CONFIG/ubuntu.common.conf
+
+ - type: user
+ before: 5
+ content: |-
+ lxc.include = LXC_TEMPLATE_CONFIG/ubuntu.userns.conf
+
+ - type: all
+ after: 4
+ content: |-
+ lxc.include = LXC_TEMPLATE_CONFIG/common.conf
+
+ - type: user
+ after: 4
+ content: |-
+ lxc.include = LXC_TEMPLATE_CONFIG/userns.conf
+
+ - type: all
+ content: |-
+ lxc.arch = {{ image.architecture_kernel }}
+
+files:
+ - path: /etc/hostname
+ generator: hostname
+
+ - path: /etc/hosts
+ generator: hosts
+
+ - path: /etc/init/lxc-tty.conf
+ generator: upstart-tty
+ releases:
+ - precise
+ - trusty
+
+files:
+ - path: /etc/hostname
+ generator: hostname
+
+ - path: /etc/hosts
+ generator: hosts
+
+ - path: /etc/resolvconf/resolv.conf.d/original
+ generator: remove
+
+ - 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:
+ - trusty
+ - xenial
+
+ - path: /etc/init/lxc-tty.conf
+ generator: upstart-tty
+ releases:
+ - precise
+ - trusty
+
+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/*-
+
+mappings:
+ architecture_map: debian
+```
+
+## With Ubuntu base image
+
+```yaml
+image:
+ distribution: ubuntu
+ release: artful
+ variant: default
+ description: Ubuntu {{ image.release }}
+ expiry: 30d
+ arch: amd64
+
+source:
+ downloader: ubuntu-http
+ url: http://cdimage.ubuntu.com/ubuntu-base
+ keys:
+ - 0x46181433FBB75451
+ - 0xD94AA3F0EFE21092
+
+targets:
+ lxc:
+ create-message: |
+ You just created an Ubuntu container (release={{ image.release }}, arch={{ image.architecture }}, variant={{ image.variant }})
+
+ config:
+ - type: all
+ before: 5
+ content: |-
+ lxc.include = LXC_TEMPLATE_CONFIG/ubuntu.common.conf
+
+ - type: user
+ before: 5
+ content: |-
+ lxc.include = LXC_TEMPLATE_CONFIG/ubuntu.userns.conf
+
+ - type: all
+ after: 4
+ content: |-
+ lxc.include = LXC_TEMPLATE_CONFIG/common.conf
+
+ - type: user
+ after: 4
+ content: |-
+ lxc.include = LXC_TEMPLATE_CONFIG/userns.conf
+
+ - type: all
+ content: |-
+ lxc.arch = {{ image.architecture_kernel }}
+
+files:
+ - path: /etc/hostname
+ generator: hostname
+
+ - path: /etc/hosts
+ generator: hosts
+
+ - path: /etc/init/lxc-tty.conf
+ generator: upstart-tty
+ releases:
+ - precise
+ - trusty
+
+packages:
+ manager: apt
+
+ update: true
+ install:
+ - systemd
+ - neovim
+
+mappings:
+ architecture_map: debian
+```
From c66f63b17329759b224eef4febb18845d927beef Mon Sep 17 00:00:00 2001
From: Thomas Hipp <thomas.hipp at canonical.com>
Date: Wed, 28 Mar 2018 15:46:36 +0200
Subject: [PATCH 2/2] Update README.md
Signed-off-by: Thomas Hipp <thomas.hipp at canonical.com>
---
README.md | 152 +++-----------------------------------------------------------
1 file changed, 5 insertions(+), 147 deletions(-)
diff --git a/README.md b/README.md
index 4c27d9b..4dceb17 100644
--- a/README.md
+++ b/README.md
@@ -6,152 +6,10 @@ Type | Service | Status
--- | --- | ---
CI | Jenkins | [![Build Status](https://travis-ci.org/lxc/distrobuilder.svg?branch=master)](https://travis-ci.org/lxc/distrobuilder)
Project status | CII Best Practices | [![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/1728/badge)](https://bestpractices.coreinfrastructure.org/projects/1728)
-## 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`.
+## Example usage
-```yaml
-image:
- distribution: ubuntu # required
- release: xenial # optional
- variant: default # optional
- description: Ubuntu Artful # optional
- expiry: 30d # optional: defaults to 30d
- architecture: x86_64 # optional: defaults to local architecture
-
-source:
- downloader: debootstrap
- url: http://us.archive.ubuntu.com/ubuntu
- keys:
- - 0x790BC7277767219C42C86F933B4FE6ACC0B21F3v
- keyserver: pgp.mit.edu # optional
-
- apt_source:: |-
- 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 {{ image.description }} container.
-
- To enable SSH, run: apt install openssh-server
- No default root or user password are set by LXC.
-
- config:
- - type: all
- before: 5
- content: |-
- lxc.include = LXC_TEMPLATE_CONFIG/ubuntu.common.conf
-
- - type: user
- before: 5
- content: |-
- lxc.include = LXC_TEMPLATE_CONFIG/ubuntu.userns.conf
-
- - type: all
- after: 4
- content: |-
- lxc.include = LXC_TEMPLATE_CONFIG/common.conf
-
- - type: user
- after: 4
- content: |-
- lxc.include = LXC_TEMPLATE_CONFIG/userns.conf
-
- - type: all
- content: |-
- lxc.arch = x86_64
-
-files:
- - path: /etc/hostname
- generator: hostname
-
- - path: /etc/hosts
- generator: hosts
-
- - path: /etc/resolvconf/resolv.conf.d/original
- generator: remove
-
- - 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:
- - trusty
- - xenial
-
- - path: /etc/init/lxc-tty.conf
- generator: upstart-tty
- releases:
- - precise
- - trusty
-
-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/*-
-
-mappings:
- architecture_map: debian
-```
+Save one of the [Ubuntu yaml snippets](./doc/examples/ubuntu.md) as
+`ubuntu.yaml`. To create a simple `Ubuntu` rootfs in a folder called
+`ubuntu-rootfs` call `distrobuilder` as `distrobuilder build-dir ubuntu.yaml
+ubuntu-rootfs`.
More information about the lxc-devel
mailing list