ublue-os / forge

On-prem Universal Blue
Apache License 2.0
27 stars 1 forks source link

Playbook to deploy test VM #35

Open tepene opened 2 months ago

tepene commented 2 months ago

Describe the feature

I'd like this project to be enhanced with a playbook which will set up a test VM where the built images can be tested because that's what this project is about. On-premises Universal Blue.

It should at least support Virtual machine manger. That's what we have available in bluefin-dx. Maybe a LXC setup would be nice too or if possible in a container directly. There's Windows in Docker so why not ublue in docker?

tepene commented 1 month ago

For virtual machines supported by libvirt we can use https://docs.ansible.com/ansible/latest/collections/community/libvirt/virt_module.html#ansible-collections-community-libvirt-virt-module

tepene commented 1 month ago

we also need a kickstart file

tepene commented 1 month ago

to create an anaconda iso which boots the kickstart file, lorax might be the thing to use

tepene commented 1 month ago

we also need a kickstart file

I did a fresh bluefin install from iso image. This is what gets created

cat /root/anaconda-ks.cfg

# Generated by Anaconda 39.32.6
# Generated by pykickstart v3.48
#version=DEVEL
# Use graphical install
graphical

%pre
#!/bin/sh

set -oue pipefail

DEFAULT_URL="ghcr.io/ublue-os/silverblue-main:39"

for ARG in `cat /proc/cmdline`; do
    if [[ "${ARG}" =~ ^imageurl= ]]; then
         URL="${ARG#*=}"
    fi
done

URL=$(echo "${URL:-${DEFAULT_URL}}" | tr "[:upper:]" "[:lower:]")

RELEASE="$(sed "2q;d" "/run/install/repo/.discinfo")"
[[ "${RELEASE}" -eq "39" ]] && RELEASE="latest"
readonly RELEASE

readonly ARCH="$(sed "3q;d" "/run/install/repo/.discinfo")"

cat << EOL > /tmp/ks-urls.txt
ostreecontainer --url="${URL}" --no-signature-verification
url --url="https://download.fedoraproject.org/pub/fedora/linux/releases/${RELEASE}/Everything/${ARCH}/os/"
EOL
%end

# Keyboard layouts
keyboard --vckeymap=ch-legacy --xlayouts='ch (legacy)'
# System language
lang en_US.UTF-8

# OSTree container setup
ostreecontainer --no-signature-verification --url="ghcr.io/ublue-os/bluefin:latest"

# Generated using Blivet version 3.8.1
ignoredisk --only-use=vda
# System bootloader configuration
bootloader --append="rd.luks.options=discard" --location=mbr --boot-drive=vda
autopart
# Partition clearing information
clearpart --none --initlabel

# System timezone
timezone Europe/Zurich

#Root password
rootpw --lock
user --groups=wheel --name=bluefin --gecos="bluefin"

some modification and templating needed, but i think this might work

tepene commented 1 month ago

with podman version > 5.0 its possible to build a bootable disk image. I currently can't test since my machine is still on GTS with podman 4.9. Maybe someone could give this a shot? I can't test before next week or so.

tepene commented 1 month ago

I'm currently not able to build an image:

❯ sudo podman run \
    --rm \
    -it \
    --add-host=registry.ublue.local:192.168.100.253 \
    --privileged \
    --pull=newer \
    --security-opt label=type:unconfined_t \
    -v $(pwd)/config.json:/config.json \
    -v $(pwd)/output:/output \
    quay.io/centos-bootc/bootc-image-builder:latest \
    --tls-verify=false --type qcow2 \
    registry.ublue.local/bluefin:latest

The --add-host=registry.ublue.local:192.168.100.253 is needed since the entry in /etc/hosts points to 127.0.0.1. The IP address has to be replaced with your computers IP. The --tls-verify=false is to disable certificate verification. If things work out as I hope i would build a custom image where the certificate for *.ublue.local would be included.

Building the image fails with:

Generating manifest manifest-qcow2.json
Error: cannot build manifest: cannot get rootfs type for container: failed to run bootc install print-configuration: exit status 1, stderr:
ERROR Loading configuration: No bootc/install config found; this operating system must define a default configuration to be installable

2024/06/03 11:05:21 error: cannot build manifest: cannot get rootfs type for container: failed to run bootc install print-configuration: exit status 1, stderr:
ERROR Loading configuration: No bootc/install config found; this operating system must define a default configuration to be installable

Maybe it's because of podman v4.9 and not 5. But I haven't found a per-requisite for this in the README.md.

I have to investigate further

tepene commented 2 weeks ago

To figure out if this is a podman version issue I followed the example:

sudo podman pull quay.io/centos-bootc/centos-bootc:stream9
sudo podman run \
    --rm \
    -it \
    --privileged \
    --pull=newer \
    --security-opt label=type:unconfined_t \
    -v $(pwd)/output:/output \
    -v /var/lib/containers/storage:/var/lib/containers/storage \
    quay.io/centos-bootc/bootc-image-builder:latest \
    --type qcow2 \
    --local \
    quay.io/centos-bootc/centos-bootc:stream9

The build was successful:

⏱  Duration: 34s
manifest - finished successfully
build:      0752f47e3c09c849c232fe0205b3cd06f1a7e32deb38d29da2e58d39ab9fe2ad
image:      bcca9f3dae637050a91cc8e526275623b9f1cc7ad505192ac54805590f70aaa9
qcow2:      85a8dc3f2ed40f98caa5b128f91f89da4f6c4fdc511294ce1b8210c0d45c2c0d
vmdk:       a3529f2be1bfbeac2adc5067ae49b7a7cb78a314379f620968b36e7330f3e008
ovf:        9dfc3bc1a8e43bf34ff307031a2aef03c9fd3b63fd18196a1b7f46f8f566fc14
archive:    372fb0dbce6827353d6ea6df3d5b7ca67000a5473d1408974d907cc1a1762d44
Build complete!
Results saved in

Trying the same with the bluefin image results in `ERROR Loading configuration: No bootc/install config found; this operating system must define a default configuration to be installable.

@castrojo any chance we can get a bootc/install config into the main ublue-os image? I currently don't know what is needed for this.

aussielunix commented 1 week ago

I have a few tasks I created for testing my images locally. These are for local libvirt/kvm and my proxmox cluster.

https://github.com/aussielunix/bootc/blob/main/justfile