[lxc-devel] [distrobuilder/master] doc: Sync examples with lxc-ci definitions

monstermunchkin on Github lxc-bot at linuxcontainers.org
Fri Jan 18 19:22:57 UTC 2019


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 385 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20190118/0539627e/attachment-0001.bin>
-------------- next part --------------
From d29bfc5f812c535f123008d85fb86967a8300744 Mon Sep 17 00:00:00 2001
From: Thomas Hipp <thomas.hipp at canonical.com>
Date: Fri, 18 Jan 2019 12:21:50 +0100
Subject: [PATCH] doc: Sync examples with lxc-ci definitions

Signed-off-by: Thomas Hipp <thomas.hipp at canonical.com>
---
 doc/examples/alpine                 |  93 ++++++++++++--
 doc/examples/centos                 | 122 ++++++++++++++++--
 doc/examples/debian                 | 110 +++++++++++++---
 doc/examples/debian-cloud-init      | 192 +++++++++++++---------------
 doc/examples/ubuntu                 | 124 +++++++++---------
 doc/examples/ubuntu-with-base-image | 104 +++++++++++++--
 6 files changed, 527 insertions(+), 218 deletions(-)

diff --git a/doc/examples/alpine b/doc/examples/alpine
index 238caa5..d034c55 100644
--- a/doc/examples/alpine
+++ b/doc/examples/alpine
@@ -1,20 +1,19 @@
 image:
-  distribution: alpinelinux
-  release: 3.7.0
-  description: Alpine Linux
-  expiry: 30d
-  architecture: x86_64
+  distribution: "alpinelinux"
+  release: 3.8
 
 source:
   downloader: alpinelinux-http
+  same_as: 3.8
   url: http://dl-cdn.alpinelinux.org/alpine/
+  keyserver: keyserver.ubuntu.com
   keys:
     - 0482D84022F52DF1C4E7CD43293ACD0907D9495A
 
 targets:
   lxc:
     create-message: |
-        You just created an Alpine container (release={{ image.release }}, arch={{ image.architecture }})
+        You just created an {{ image.description }} container.
 
     config:
       - type: all
@@ -39,7 +38,7 @@ targets:
 
       - type: all
         content: |-
-          lxc.arch = {{ image.architecture_kernel }}
+          lxc.arch = {{ image.architecture_personality }}
 
 files:
  - path: /etc/hostname
@@ -48,13 +47,79 @@ files:
  - path: /etc/hosts
    generator: hosts
 
+ - path: /etc/network/interfaces
+   generator: dump
+   content: |-
+     auto eth0
+     iface eth0 inet dhcp
+     hostname $(hostname)
+
+ - path: /etc/inittab
+   generator: dump
+   content: |-
+     # /etc/inittab
+     ::sysinit:/sbin/openrc sysinit
+     ::sysinit:/sbin/openrc boot
+     ::wait:/sbin/openrc default
+
+     # Set up a couple of getty's
+     ::respawn:/sbin/getty 38400 console
+     tty1::respawn:/sbin/getty 38400 tty1
+     tty2::respawn:/sbin/getty 38400 tty2
+     tty3::respawn:/sbin/getty 38400 tty3
+     tty4::respawn:/sbin/getty 38400 tty4
+
+     # Stuff to do for the 3-finger salute
+     ::ctrlaltdel:/sbin/reboot
+
+     # Stuff to do before rebooting
+     ::shutdown:/sbin/openrc shutdown
+
+ - path: /etc/inittab
+   generator: template
+   name: inittab
+   content: |-
+     # /etc/inittab
+     ::sysinit:/sbin/openrc sysinit
+     ::sysinit:/sbin/openrc boot
+     ::wait:/sbin/openrc default
+
+     # Set up a couple of getty's
+     ::respawn:/sbin/getty 38400 console
+
+     # Stuff to do for the 3-finger salute
+     ::ctrlaltdel:/sbin/reboot
+
+     # Stuff to do before rebooting
+     ::shutdown:/sbin/openrc shutdown
+
 packages:
-    manager: apk
+  manager: apk
+  update: true
+  cleanup: true
+
+  sets:
+    - packages:
+      - alpine-base
+      action: install
+
+actions:
+  - trigger: post-packages
+    action: |-
+      #!/bin/sh
+      set -eux
+
+      # Rewrite configuration for LXC
+      sed -i 's/#rc_sys=""/rc_sys="lxc"/' /etc/rc.conf
+
+      # Enable services
+      for svc_name in bootmisc syslog; do
+          ln -s /etc/init.d/${svc_name} /etc/runlevels/boot/${svc_name}
+      done
 
-    update: true
-    cleanup: true
+      for svc_name in networking crond; do
+          ln -s /etc/init.d/${svc_name} /etc/runlevels/default/${svc_name}
+      done
 
-    sets:
-      - packages:
-          - neovim
-        action: install
+mappings:
+  architecture_map: alpinelinux
diff --git a/doc/examples/centos b/doc/examples/centos
index e0e76c6..1e7a5e4 100644
--- a/doc/examples/centos
+++ b/doc/examples/centos
@@ -1,23 +1,20 @@
 image:
   distribution: centos
   release: 7
-  variant: Minimal
-  description: CentOS {{ image.release }}
-  expiry: 30d
-  architecture: x86_64
 
 source:
   downloader: centos-http
-  url: http://centos.uib.no
+  url: http://centos.mirror.iweb.ca
+  keyserver: keyserver.ubuntu.com
   keys:
-    - 24C6A8A7F4A80EB5
-    - 0946FCA2C105B9DE
-  variant: Minimal
+    - 6341AB2753D78A78A7C27BB124C6A8A7F4A80EB5
+    - C1DAC52D1664E8A4386DBA430946FCA2C105B9DE
+  variant: minimal
 
 targets:
   lxc:
     create-message: |
-        You just created a CentOS container (release={{ image.release }}, arch={{ image.architecture }})
+        You just created a {{ image.description }} container.
 
     config:
       - type: all
@@ -53,13 +50,112 @@ files:
    path: /etc/hosts
    generator: hosts
 
+ - name: ifcfg-eth0
+   path: /etc/sysconfig/network-scripts/ifcfg-eth0
+   generator: dump
+   templated: true
+   content: |-
+     DEVICE=eth0
+     BOOTPROTO=dhcp
+     ONBOOT=yes
+     HOSTNAME=LXC_NAME
+     NM_CONTROLLED=no
+     TYPE=Ethernet
+     MTU=
+     DHCP_HOSTNAME=`hostname`
+
+ - name: network
+   path: /etc/sysconfig/network
+   generator: dump
+   templated: true
+   content: |-
+     NETWORKING=yes
+     HOSTNAME=LXC_NAME
+
+ - name: ifcfg-eth0.lxd
+   path: /etc/sysconfig/network-scripts/ifcfg-eth0
+   generator: template
+   content: |-
+     DEVICE=eth0
+     BOOTPROTO=dhcp
+     ONBOOT=yes
+     HOSTNAME={{ container.name }}
+     NM_CONTROLLED=no
+     TYPE=Ethernet
+     MTU=
+     DHCP_HOSTNAME=`hostname`
+
+ - name: network.lxd
+   path: /etc/sysconfig/network
+   generator: template
+   content: |-
+     NETWORKING=yes
+     HOSTNAME={{ container.name }}
+
+ - name: lxc-sysinit
+   path: /etc/init/lxc-sysinit.conf
+   generator: dump
+   content: |-
+     start on startup
+     env container
+
+     pre-start script
+         if [ "x$container" != "xlxc" -a "x$container" != "xlibvirt" ]; then
+             stop;
+         fi
+
+         rm -f /var/lock/subsys/*
+         rm -f /var/run/*.pid
+         [ -e /etc/mtab ] || ln -s /proc/mounts /etc/mtab
+         mkdir -p /dev/shm
+         mount -t tmpfs -o nosuid,nodev tmpfs /dev/shm
+
+         initctl start tty TTY=console
+         telinit 3
+         exit 0
+     end script
+   releases:
+    - 6
+
+ - name: sigpwr.conf
+   path: /etc/init/power-status-changed.conf
+   generator: dump
+   content: |-
+     start on power-status-changed
+
+     exec /sbin/shutdown -h now "SIGPWR received"
+   releases:
+    - 6
+
 packages:
     manager: yum
-
     update: true
     cleanup: true
 
     sets:
-      - packages:
-          - vim
-        action: install
+     - packages:
+        - cronie
+        - cronie-noanacron
+        - curl
+        - dhclient
+        - initscripts
+        - openssh-clients
+        - passwd
+        - policycoreutils
+        - rootfiles
+        - rsyslog
+        - vim-minimal
+       action: install
+
+actions:
+  - trigger: post-packages
+    action: |-
+      #!/bin/sh
+      set -eux
+
+      # Disable SELinux
+      mkdir -p /selinux
+      echo 0 > /selinux/enforce
+
+      # Disable loginuid in PAM stack
+      sed -i '/^session.*pam_loginuid.so/s/^session/# session/' /etc/pam.d/*
diff --git a/doc/examples/debian b/doc/examples/debian
index 7a88122..41307d0 100644
--- a/doc/examples/debian
+++ b/doc/examples/debian
@@ -1,16 +1,26 @@
 image:
-  distribution: debian
+  distribution: "debian"
   release: testing
-  description: Debian testing
-  expiry: 30d
 
 source:
   downloader: debootstrap
+  url: http://deb.debian.org/debian
+  keyserver: keyserver.ubuntu.com
+  keys:
+    - 0x126C0D24BD8A2942CC7DF8AC7638D0442B90D010
+    - 0xA1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553
+  variant: minbase
+  apt_sources: |-
+    deb http://deb.debian.org/debian {{ image.release }} main
+    {% if image.release != "sid" and image.release != "buster" and not (image.release == "wheezy" and image.architecture_mapped == "powerpc") and not (image.release == "wheezy" and image.architecture_mapped == "s390x") %}deb http://security.debian.org/debian-security {{ image.release }}/updates main{% endif %}
 
 targets:
   lxc:
-    create-message: |
-        You just created a Debian container (release={{ image.release }}, arch={{ image.architecture }}, variant={{ image.variant }})
+    create-message: |-
+      You just created a {{ image.description }} container.
+
+      To enable SSH, run: apt install openssh-server
+      No default root or user password are set by LXC.
 
     config:
       - type: all
@@ -35,28 +45,92 @@ targets:
 
       - type: all
         content: |-
-          lxc.arch = {{ image.architecture_kernel }}
+          lxc.arch = {{ image.architecture_personality }}
 
 files:
- - name: hostname
-   path: /etc/hostname
+ - path: /etc/hostname
    generator: hostname
 
- - name: hosts
-   path: /etc/hosts
+ - 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/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
+
 packages:
-    manager: apt
+  manager: apt
+  update: true
+  cleanup: true
+
+  sets:
+    - packages:
+      - dialog
+      - ifupdown
+      - isc-dhcp-client
+      - locales
+      - netbase
+      - net-tools
+      - openssh-client
+      - vim
+      - systemd
+      action: install
+
+actions:
+  - trigger: post-packages
+    action: |-
+      #!/bin/sh
+      set -eux
+
+      # Make sure the locale is built and functional
+      echo en_US.UTF-8 UTF-8 >> /etc/locale.gen
+      locale-gen en_US.UTF-8 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/*-
 
-    update: true
-    cleanup: true
+  - trigger: post-packages
+    action: |-
+      #!/bin/sh
+      set -eux
+      apt-get install iproute sysvinit -y
+    releases:
+      - wheezy
 
-    sets:
-      - packages:
-          - systemd
-          - neovim
-        action: install
+  - trigger: post-packages
+    action: |-
+      #!/bin/sh
+      set -eux
+      apt-get install iproute2 init -y
+    releases:
+      - jessie
+      - stretch
+      - buster
+      - sid
 
 mappings:
   architecture_map: debian
diff --git a/doc/examples/debian-cloud-init b/doc/examples/debian-cloud-init
index 154afb5..3b60956 100644
--- a/doc/examples/debian-cloud-init
+++ b/doc/examples/debian-cloud-init
@@ -6,11 +6,17 @@ image:
 
 source:
   downloader: debootstrap
+  apt_sources: |-
+    deb http://deb.debian.org/debian {{ image.release }} main
+    {% if image.release != "sid" and image.release != "buster" and not (image.release == "wheezy" and image.architecture_mapped == "powerpc") and not (image.release == "wheezy" and image.architecture_mapped == "s390x") %}deb http://security.debian.org/debian-security {{ image.release }}/updates main{% endif %}
 
 targets:
   lxc:
-    create-message: |
-        You just created a Debian container (release={{ image.release }}, arch={{ image.architecture }}, variant={{ image.variant }})
+    create-message: |-
+      You just created a {{ image.description }} container.
+
+      To enable SSH, run: apt install openssh-server
+      No default root or user password are set by LXC.
 
     config:
       - type: all
@@ -35,111 +41,91 @@ targets:
 
       - type: all
         content: |-
-          lxc.arch = {{ image.architecture_kernel }}
+          lxc.arch = {{ image.architecture_personality }}
 
 files:
-  - name: interfaces
-    generator: dump
-    path: /etc/network/interfaces
-    content: |
-      # interfaces(5) file used by ifup(8) and ifdown(8)
-      # Include files from /etc/network/interfaces.d:
-      source-directory /etc/network/interfaces.d
-      source /etc/network/interfaces.d/50-cloud-init.cfg
-
-  - name: hostname
-    path: /etc/hostname
-    generator: hostname
-
-  - name: hosts
-    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
-
-  - name: cloud-init-meta
-    path: /var/lib/cloud/seed/nocloud-net/meta-data
-    generator: template
-    template:
-      when:
-        - create
-        - copy
-    content: |
-      #cloud-config
-      instance-id: {{ container.name }}
-      local-hostname: {{ container.name }}
-      {{ config_get("user.meta-data", "") }}
-
-  - name: cloud-init-network
-    path: /var/lib/cloud/seed/nocloud-net/network-config
-    generator: template
-    template:
-      when:
-        - create
-        - copy
-    content: |
-      {% if config_get("user.network-config", "") == "" %}version: 1
-      config:
-         - type: physical
-           name: eth0
-           subnets:
-               - type: {% if config_get("user.network_mode", "") == "link-local" %}manual{% else %}dhcp{% endif %}
-                 control: auto{% else %}{{ config_get("user.network-config", "") }}{% endif %}
-
-  - name: cloud-init-user-data
-    path: /var/lib/cloud/seed/nocloud-net/user-data
-    generator: template
-    content: '{{ config_get("user.user-data", properties.default) }}'
-    template:
-      properties:
-        default: |
-          #cloud-config
-          {}
-      when:
-        - create
-        - copy
-
-  - name: cloud-init-vedor-data
-    path: /var/lib/cloud/seed/nocloud-net/vendor-data
-    generator: template
-    content: '{{ config_get("user.vendor-data", properties.default) }}'
-    template:
-      properties:
-        default: |
-          #cloud-config
-          {}
-      when:
-        - create
-        - copy
+ - 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/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
 
 packages:
-    manager: apt
-
-    update: true
-    cleanup: true
-
-    sets:
-      - packages:
-          - systemd
-          - dialog
-          - ifupdown
-          - locales
-          - netbase
-          - net-tools
-          - cloud-init
-          - cloud-utils
-          - sudo
-          - adduser
-          - locales
-          - file
-          - openssh-server
-        action: install
+  manager: apt
+  update: true
+  cleanup: true
+
+  sets:
+    - packages:
+      - dialog
+      - ifupdown
+      - isc-dhcp-client
+      - locales
+      - netbase
+      - net-tools
+      - openssh-client
+      - vim
+      action: install
+
+actions:
+  - trigger: post-packages
+    action: |-
+      #!/bin/sh
+      set -eux
+
+      # Make sure the locale is built and functional
+      echo en_US.UTF-8 UTF-8 >> /etc/locale.gen
+      locale-gen en_US.UTF-8 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/*-
+
+  - trigger: post-packages
+    action: |-
+      #!/bin/sh
+      set -eux
+      apt-get install iproute sysvinit -y
+    releases:
+      - wheezy
+
+  - trigger: post-packages
+    action: |-
+      #!/bin/sh
+      set -eux
+      apt-get install iproute2 init -y
+    releases:
+      - jessie
+      - stretch
+      - buster
+      - sid
 
 mappings:
   architecture_map: debian
diff --git a/doc/examples/ubuntu b/doc/examples/ubuntu
index 06de002..830ea65 100644
--- a/doc/examples/ubuntu
+++ b/doc/examples/ubuntu
@@ -1,24 +1,27 @@
 image:
-  distribution: ubuntu
-  release: artful
-  description: Ubuntu {{ image.release }}
-  architecture: amd64
+  distribution: "ubuntu"
+  release: cosmic
 
 source:
   downloader: debootstrap
-  url: http://us.archive.ubuntu.com/ubuntu
+  same_as: gutsy
+  url: http://archive.ubuntu.com/ubuntu
+  keyserver: keyserver.ubuntu.com
   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
+    {% if image.architecture_mapped == "amd64" or image.architecture_mapped == "i386" %}deb http://archive.ubuntu.com/ubuntu {{ image.release }} main restricted universe multiverse
+    deb http://archive.ubuntu.com/ubuntu {{ image.release }}-updates main restricted universe multiverse
     deb http://security.ubuntu.com/ubuntu {{ image.release }}-security main restricted universe multiverse
+    {% else %}deb http://ports.ubuntu.com/ubuntu-ports {{ image.release }} main restricted universe multiverse
+    deb http://ports.ubuntu.com/ubuntu-ports {{ image.release }}-updates main restricted universe multiverse
+    deb http://ports.ubuntu.com/ubuntu-ports {{ image.release }}-security main restricted universe multiverse
+    {% endif %}
 
 targets:
   lxc:
-    create-message: |
+    create-message: |-
       You just created an {{ image.description }} container.
 
       To enable SSH, run: apt install openssh-server
@@ -40,27 +43,24 @@ targets:
         content: |-
           lxc.include = LXC_TEMPLATE_CONFIG/common.conf
 
+          # For Ubuntu 14.04
+          lxc.mount.entry = /sys/kernel/debug sys/kernel/debug none bind,optional 0 0
+          lxc.mount.entry = /sys/kernel/security sys/kernel/security none bind,optional 0 0
+          lxc.mount.entry = /sys/fs/pstore sys/fs/pstore none bind,optional 0 0
+          lxc.mount.entry = mqueue dev/mqueue mqueue rw,relatime,create=dir,optional 0 0
+
       - type: user
         after: 4
         content: |-
           lxc.include = LXC_TEMPLATE_CONFIG/userns.conf
 
+          # For Ubuntu 14.04
+          lxc.mount.entry = /sys/firmware/efi/efivars sys/firmware/efi/efivars none bind,optional 0 0
+          lxc.mount.entry = /proc/sys/fs/binfmt_misc proc/sys/fs/binfmt_misc none bind,optional 0 0
+
       - 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
+          lxc.arch = {{ image.architecture_personality }}
 
 files:
  - path: /etc/hostname
@@ -82,12 +82,14 @@ files:
    generator: dump
    content: |-
      network:
+       version: 2
        ethernets:
          eth0: {dhcp4: true}
-     version: 2
    releases:
      - artful
      - bionic
+     - cosmic
+     - disco
 
  - path: /etc/network/interfaces
    generator: dump
@@ -108,49 +110,47 @@ files:
  - path: /etc/init/lxc-tty.conf
    generator: upstart-tty
    releases:
-    - precise
     - trusty
 
 packages:
-    manager: apt
-
-    update: true
-    cleanup: true
-
-    sets:
-      - packages:
-          - apt-transport-https
-          - language-pack-en
-          - openssh-client
-          - vim
-        action: install
+  manager: apt
+  update: true
+  cleanup: true
+
+  sets:
+    - packages:
+      - apt-transport-https
+      - language-pack-en
+      - openssh-client
+      - vim
+      action: install
 
 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/*-
+  - 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
diff --git a/doc/examples/ubuntu-with-base-image b/doc/examples/ubuntu-with-base-image
index eb80c6d..118585a 100644
--- a/doc/examples/ubuntu-with-base-image
+++ b/doc/examples/ubuntu-with-base-image
@@ -1,6 +1,6 @@
 image:
   distribution: ubuntu
-  release: artful
+  release: cosmic
   variant: default
   description: Ubuntu {{ image.release }}
   expiry: 30d
@@ -13,10 +13,22 @@ source:
     - 0x46181433FBB75451
     - 0xD94AA3F0EFE21092
 
+  apt_sources: |-
+    {% if image.architecture_mapped == "amd64" or image.architecture_mapped == "i386" %}deb http://archive.ubuntu.com/ubuntu {{ image.release }} main restricted universe multiverse
+    deb http://archive.ubuntu.com/ubuntu {{ image.release }}-updates main restricted universe multiverse
+    deb http://security.ubuntu.com/ubuntu {{ image.release }}-security main restricted universe multiverse
+    {% else %}deb http://ports.ubuntu.com/ubuntu-ports {{ image.release }} main restricted universe multiverse
+    deb http://ports.ubuntu.com/ubuntu-ports {{ image.release }}-updates main restricted universe multiverse
+    deb http://ports.ubuntu.com/ubuntu-ports {{ image.release }}-security main restricted universe multiverse
+    {% endif %}
+
 targets:
   lxc:
-    create-message: |
-        You just created an Ubuntu container (release={{ image.release }}, arch={{ image.architecture }}, variant={{ image.variant }})
+    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
@@ -34,14 +46,24 @@ targets:
         content: |-
           lxc.include = LXC_TEMPLATE_CONFIG/common.conf
 
+          # For Ubuntu 14.04
+          lxc.mount.entry = /sys/kernel/debug sys/kernel/debug none bind,optional 0 0
+          lxc.mount.entry = /sys/kernel/security sys/kernel/security none bind,optional 0 0
+          lxc.mount.entry = /sys/fs/pstore sys/fs/pstore none bind,optional 0 0
+          lxc.mount.entry = mqueue dev/mqueue mqueue rw,relatime,create=dir,optional 0 0
+
       - type: user
         after: 4
         content: |-
           lxc.include = LXC_TEMPLATE_CONFIG/userns.conf
 
+          # For Ubuntu 14.04
+          lxc.mount.entry = /sys/firmware/efi/efivars sys/firmware/efi/efivars none bind,optional 0 0
+          lxc.mount.entry = /proc/sys/fs/binfmt_misc proc/sys/fs/binfmt_misc none bind,optional 0 0
+
       - type: all
         content: |-
-          lxc.arch = {{ image.architecture_kernel }}
+          lxc.arch = {{ image.architecture_personality }}
 
 files:
  - path: /etc/hostname
@@ -50,23 +72,89 @@ files:
  - 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:
+       version: 2
+       ethernets:
+         eth0: {dhcp4: true}
+   releases:
+     - artful
+     - bionic
+     - cosmic
+     - disco
+
+ - 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
   cleanup: true
 
   sets:
     - packages:
-        - systemd
-        - neovim
+      - apt-transport-https
+      - language-pack-en
+      - openssh-client
+      - vim
+      - systemd
       action: install
 
+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


More information about the lxc-devel mailing list