Last active
January 3, 2026 22:37
-
-
Save ricardobalk/45188ef7efb7439148a762ef6434d883 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| https://github.com/wlanboy/debian-cloud-init |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| IMAGE_URL="https://cloud.debian.org/images/cloud/trixie/latest/debian-13-genericcloud-${IMAGE_ARCH}.qcow2" | |
| BASE_IMAGE="$WORKDIR/debian-13-base-${IMAGE_ARCH}.qcow2" | |
| DISK_IMAGE="$WORKDIR/${VM_NAME}-${IMAGE_ARCH}.qcow2" | |
| SEED_IMAGE="$WORKDIR/${VM_NAME}-${IMAGE_ARCH}-seed.iso" | |
| mkdir -p "$WORKDIR" | |
| ### --- base image ------------------------------------------------------------ | |
| if [[ ! -f "$BASE_IMAGE" ]]; then | |
| echo "[e2e-libvirt] Downloading Debian 13 cloud image (${IMAGE_ARCH})" | |
| curl -L "$IMAGE_URL" -o "$BASE_IMAGE" | |
| fi | |
| if [[ ! -f "$DISK_IMAGE" ]]; then | |
| echo "[e2e-libvirt] Creating qcow2 overlay" | |
| qemu-img create \ | |
| -f qcow2 \ | |
| -b "$BASE_IMAGE" \ | |
| -F qcow2 \ | |
| "$DISK_IMAGE" \ | |
| "$DISK_SIZE" >/dev/null | |
| fi | |
| ### --- cloud-init data ------------------------------------------------------- | |
| PUBKEY_CONTENT=$(<"$SSH_KEY_FILE") | |
| USER_DATA="$WORKDIR/user-data" | |
| META_DATA="$WORKDIR/meta-data" | |
| cat >"$USER_DATA" <<EOF | |
| #cloud-config | |
| users: | |
| - name: $SSH_USER | |
| sudo: ALL=(ALL) NOPASSWD:ALL | |
| shell: /bin/bash | |
| ssh_authorized_keys: | |
| - "$PUBKEY_CONTENT" | |
| package_update: true | |
| packages: | |
| - python3 | |
| - python3-apt | |
| - sudo | |
| - openssh-server | |
| EOF | |
| cat >"$META_DATA" <<EOF | |
| instance-id: $VM_NAME | |
| local-hostname: $VM_NAME | |
| EOF | |
| ### --- seed ISO (portable) --------------------------------------------------- | |
| if command -v genisoimage >/dev/null 2>&1; then | |
| ISO_TOOL=genisoimage | |
| elif command -v mkisofs >/dev/null 2>&1; then | |
| ISO_TOOL=mkisofs | |
| else | |
| die "Missing ISO tool: install genisoimage or mkisofs" | |
| fi | |
| echo "[e2e-libvirt] Creating cloud-init seed ISO via $ISO_TOOL" | |
| "$ISO_TOOL" \ | |
| -output "$SEED_IMAGE" \ | |
| -volid cidata \ | |
| -joliet \ | |
| -rock \ | |
| "$USER_DATA" \ | |
| "$META_DATA" | |
| >/dev/null | |
| qemu-system-aarch64 \ | |
| -machine virt,highmem=on \ | |
| -accel hvf \ | |
| -cpu host \ | |
| -smp "$VCPUS" \ | |
| -m "$MEMORY_MB" \ | |
| \ | |
| -drive if=none,file="$DISK_IMAGE",format=qcow2,id=hd0 \ | |
| -device virtio-blk-pci,drive=hd0 \ | |
| \ | |
| -drive if=none,file="$SEED_IMAGE",format=raw,id=cidata \ | |
| -device virtio-blk-pci,drive=cidata \ | |
| \ | |
| -netdev vmnet-bridged,ifname=en0,id=net0 \ | |
| -device virtio-net-pci,netdev=net0 \ | |
| \ | |
| -display cocoa | |
| # -nographic |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
--cloud-init user-data=/isos/cloud-init.yml \