Commit 76d7ce41 authored by Benjamin Tissoires's avatar Benjamin Tissoires
Browse files

qemu-base-image: embed a current Fedora cloud image in the base image



This image will be used to run mkosi which will generate the various
final VM images. However, the final container image will not be based
on this container, but on the qemu one.
Signed-off-by: Benjamin Tissoires's avatarBenjamin Tissoires <benjamin.tissoires@gmail.com>
parent d3a711b1
......@@ -68,7 +68,7 @@ include:
variables:
BOOTSTRAP_TAG: '2019-12-02'
QEMU_TAG: '2019-12-03'
QEMU_TAG: '2019-12-10'
stages:
......@@ -153,4 +153,12 @@ bootstrap-qemu:
extends: .qemu
needs:
- sanity check
- bootstrap
bootstrap-qemu-mkosi:
extends: .qemu-mkosi
needs:
- sanity check
- check commits
- bootstrap
\ No newline at end of file
......@@ -175,3 +175,16 @@
REPO_SUFFIX: qemu-base
FEDORA_RPMS: 'buildah podman skopeo jq git qemu genisoimage usbutils'
FEDORA_EXEC: 'bootstrap/prep_qemu.sh'
# qemu container capable of creating an other VM image
#
.qemu-mkosi:
extends: .qemu
tags:
- kvm
variables:
FEDORA_VERSION: '31'
FEDORA_TAG: $QEMU_TAG
REPO_SUFFIX: qemu-mkosi-base
FEDORA_RPMS: 'buildah podman skopeo jq git qemu genisoimage usbutils'
FEDORA_EXEC: 'bootstrap/prep_qemu.sh && bootstrap/prep_mkosi.sh'
#!/bin/bash
set -e
set -x
FEDORA_TARGET_RELEASE=31
CLOUD_IMAGE_URL="https://download.fedoraproject.org/pub/fedora/linux/releases/31/Cloud/x86_64/images/Fedora-Cloud-Base-31-1.9.x86_64.raw.xz"
pushd /app
curl -L $CLOUD_IMAGE_URL -o /app/image.raw.xz
# create a common ssh key that will be used to generate the final VM images
ssh-keygen -t rsa -f /root/.ssh/id_rsa -N ''
# to start the cloud-init ready image we need to provide it some input:
# https://blog.christophersmart.com/2016/06/17/booting-fedora-24-cloud-image-with-kvm/
cat > /app/meta-data << EOF
instance-id: Cloud00
local-hostname: cloud-00
EOF
cat > /app/user-data << EOF
#cloud-config
# Set the default user
system_info:
default_user:
name: cloud
# Unlock the default and root users
chpasswd:
list: |
cloud:password
root:root
expire: False
# Other settings
resize_rootfs: True
ssh_pwauth: True
disable_root: false
timezone: Australia/Sydney
# Add any ssh public keys
ssh_authorized_keys:
- $(cat /root/.ssh/id_rsa.pub)
bootcmd:
- [ sh, -c, echo "=========bootcmd=========" ]
runcmd:
- [ sh, -c, echo "=========runcmd=========" ]
final_message: "SYSTEM READY TO LOG IN"
EOF
genisoimage -output /app/my-seed.iso \
-volid cidata \
-joliet \
-rock /app/user-data /app/meta-data
# do some initial preparation in the target VM so it is mkosi capable
/app/start_vm.sh -cdrom /app/my-seed.iso
# install mkosi dependencies to build up our final VM image
ssh localhost -p 5555 dnf install -y mkosi systemd-container
# use the upstream mkosi code
ssh localhost -p 5555 git clone https://github.com/systemd/mkosi.git
# stop the vm and compress the image file
ssh localhost -p 5555 halt -p || true
sleep 2
# manually compress the image with `-T0` to use multithreading
xz -T0 /app/image.raw
popd
......@@ -137,4 +137,4 @@ globals:
bootstrap_tag: '2019-12-02'
## @qemu_tag: the current image tag associated with this qemu bootstrap image
qemu_tag: '2019-12-03'
qemu_tag: '2019-12-10'
......@@ -98,3 +98,11 @@ bootstrap-qemu:
needs:
- sanity check
- bootstrap
bootstrap-qemu-mkosi:
extends: .qemu-mkosi
needs:
- sanity check
- check commits
- bootstrap
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment