2 # based on https://github.com/lxc/lxc-ci/blob/main/images/opensuse.yaml
11 - key: SLES_REGISTRATION_CODE
12 value: XXSLES_REGISTRATION_CODE_amd64XX
14 # This rootfs requires some preparation
15 # 1. Download the SLES qemu-kvm minimal image
16 # 2. Use qemu-nbd to map the image to a device
17 # `qemu-nbd -c /dev/nbd0 /path/to/SLES-qemu-kvm.img`
18 # 3. Mount the principal btrfs partition on /mnt
19 # * Note: the SLES images make extensive use of btrfs subvols
20 # for /home, /opt, /root/, /srv, various direcotries inside /var,
21 # /boot/grub2/*, /usr/local/, and more. The mappings can be found
23 # * For lxd/incus, the rootfs will be ext4; however, to prepare the
24 # initial archive many of the subvols will need to mounted.
25 # 4. Bind mount /dev/ to /mnt/dev
26 # `for i in dev proc sys ; do mount -o bind /$i /mnt/$i ; done`
27 # 5. ***Using chroot in /mnt*** mount the subvols
28 # `chroot /mnt mount -a`
30 # @TODO: Register and install more or the packages (eg., kernel) to avoid
31 # redoing the work each time an image is built from the rootfs.
33 # 6. Outside the chroot, prepare the archive file
34 # `tar -czf /path/to/rootfs.tgz -C /mnt --exclude './.snapshots/*' \
35 # --exclude './dev/*' --exclude './proc/*' --exclude './sys/*' ./`
36 # 7. Unmount bind mounts
37 # `for i in $(findmnt -R -l -k -n -o TARGET /mnt) ; do umount $i; done; umount /mnt`
38 # 8. Disconnect the nbd device
39 # `qemu-nbd -d /dev/nbd0`
42 downloader: rootfs-http
43 url: https://obj.internal.efficios.com/jenkins/rootfs_amd64_sles12sp5.tar.gz
48 You just created an {{ image.description }} container.
53 lxc.include = LXC_TEMPLATE_CONFIG/opensuse.common.conf
58 lxc.include = LXC_TEMPLATE_CONFIG/opensuse.userns.conf
63 lxc.include = LXC_TEMPLATE_CONFIG/common.conf
68 lxc.include = LXC_TEMPLATE_CONFIG/userns.conf
72 lxc.arch = {{ image.architecture_kernel }}
83 - path: /etc/machine-id
86 - path: /var/lib/dbus/machine-id
90 path: /etc/sysconfig/network/ifcfg-eth0
102 generator: cloud-init
110 - generator: incus-agent
114 - path: /etc/dracut.conf.d/incus.conf
117 add_drivers+=" virtio_scsi virtio_pci sd_mod "
123 content: "# empty fstab to silence cloud-init warnings"
140 - trigger: post-unpack
145 systemd-machine-id-setup
146 mount -t tmpfs tmpfs /sys/firmware
150 - trigger: post-unpack
155 SUSEConnect -r $SLES_REGISTRATION_CODE
158 - trigger: post-packages
161 # Fails during the packages step due to not supporting `--allow-downgrades`
162 zypper --non-interactive --gpg-auto-import-keys install elfutils \
163 glib2-tools gzip iproute2 iputils openssh pigz rsync sudo which xz
165 - trigger: post-packages
168 # Fails during the packages step due to not supporting `--allow-downgrades`
169 zypper --non-interactive --gpg-auto-import-keys install shim
175 - trigger: post-packages
178 # Fails during the packages step due to not supporting `--allow-downgrades`
179 zypper --non-interactive --gpg-auto-import-keys install e2fsprogs
183 - trigger: post-packages
188 # Install cloud-init from a separate product
189 SUSEConnect --product sle-module-public-cloud/12/x86_64
190 zypper --non-interactive --gpg-auto-import-keys install cloud-init-config-suse cloud-init
192 # Enable the cloud-init systemd service
193 systemctl enable cloud-init.service cloud-config.service cloud-final.service
197 - trigger: post-files
202 for mod in virtio_scsi virtio_pci sd_mod ; do
203 echo "install $mod /bin/true" >> /etc/modprobe.d/99-local.conf
206 # This gets around the kernel-default installation failing
207 dracut --regenerate-all --force
208 mount -t tmpfs tmpfs /sys/firmware
209 mkdir /sys/firmware/efi
210 grub2-mkconfig -o /boot/grub2/grub.cfg
212 if which shim-install; then
213 shim-install --no-nvram --removable
214 shim-install --no-nvram
216 grub2-install --no-nvram --removable
217 grub2-install --no-nvram
220 grub2-mkconfig -o /boot/grub2/grub.cfg
221 sed -i "s#root=[^ ]*#root=/dev/sda2#g" /boot/grub2/grub.cfg
222 zypper --non-interactive install kernel-default
224 # If this isn't re-done, the VM won't boot
225 dracut --regenerate-all --force --add-drivers 'virtio_scsi virtio_pci sd_mod'
226 grub2-mkconfig -o /boot/grub2/grub.cfg
228 if which shim-install; then
229 shim-install --no-nvram --removable
230 shim-install --no-nvram
232 grub2-install --no-nvram --removable
233 grub2-install --no-nvram
236 grub2-mkconfig -o /boot/grub2/grub.cfg
237 sed -i "s#root=[^ ]*#root=/dev/sda2#g" /boot/grub2/grub.cfg
243 - trigger: post-files
248 umount -l /etc/resolv.conf || true
250 ln -sf /var/run/netconfig/resolv.conf /etc/resolv.conf
252 - trigger: post-files
257 # Automatic disk resize
258 cat << EOF > /etc/systemd/system/incus-growpart.service
260 Description=Incus - grow root partition
264 ExecStartPre=-/usr/sbin/growpart /dev/sda 2
265 ExecStart=/usr/sbin/resize2fs /dev/sda2
268 WantedBy=default.target
270 systemctl enable incus-growpart
274 - trigger: post-files
279 # By default, sles systems don't check authorized_keys2,
281 sed -E -i 's/^AuthorizedKeysFile[\t ]+.ssh\/authorized_keys$/AuthorizedKeysFile .ssh\/authorized_keys .ssh\/authorized_keys2/g' /etc/ssh/sshd_config