refactor: Justfile ISO-only, seed mit Helfern/Backups/Anker-WARN

This commit is contained in:
humocs-man committed 2026-10-10 17:07:22 +02:00
1 parent b4976ed44f
commit 00ecfa5778
3 files changed
+132 -156

No files matched your search

+16 -65
View File
@@ -3,9 +3,9 @@ export image_name := env("IMAGE_NAME", "fluffy-pancake")
export default_tag := env("DEFAULT_TAG", "stable")
export bib_image := env("BIB_IMAGE", "quay.io/centos-bootc/bootc-image-builder:latest")
alias build-vm := build-qcow2
alias rebuild-vm := rebuild-qcow2
alias run-vm := run-vm-qcow2
alias build-vm := build-iso
alias rebuild-vm := rebuild-iso
alias run-vm := run-vm-iso
[private]
default:
@@ -70,9 +70,19 @@ sudoif command *args:
sudoif {{ command }} {{ args }}
# Build the local image using Podman from Containerfile
# HINWEIS: Lokal wird nur das Container-Image + ISO gebaut (kein qcow2/raw).
# configs/auth.json liegt NICHT im Repo (gitignored, Secret) - fehlt die
# Datei, wird sie aus dem Template mit Dummy-Token angelegt, damit der
# lokale Build nicht an COPY scheitert. CI erzeugt die echte Datei selbst.
build $target_image=image_name $tag=default_tag:
#!/usr/bin/env bash
if [[ ! -f configs/auth.json ]]; then
echo "==> Kein configs/auth.json - lege Dummy aus Template an (nur lokaler Build)"
sed "s|READONLY_TOKEN_PLACEHOLDER|LOCAL-DEV-DUMMY|g" \
configs/auth.json.template > configs/auth.json
fi
BUILD_ARGS=()
if [[ -z "$(git status -s)" ]]; then
BUILD_ARGS+=("--build-arg" "SHA_HEAD_SHORT=$(git rev-parse --short HEAD)")
@@ -171,74 +181,23 @@ _build-bib $target_image $tag $type $config: (_rootful_load_image target_image t
_rebuild-bib $target_image $tag $type $config: (build target_image tag) && (_build-bib target_image tag type config)
# ==============================================================================
# BUILD TARGETS (Pullen aus Remote-Registry)
# BUILD TARGETS (Pullen aus Remote-Registry, nur ISO - kein qcow2/raw)
# ==============================================================================
# Build a QCOW2 virtual machine image from Registry
[group('Build Virtual Machine Image')]
build-qcow2 $target_image=(registry + "/" + image_name) $tag=default_tag: && (_build-bib target_image tag "qcow2" "iso/disk.toml")
# Build a RAW virtual machine image from Registry
[group('Build Virtual Machine Image')]
build-raw $target_image=(registry + "/" + image_name) $tag=default_tag: && (_build-bib target_image tag "raw" "iso/disk.toml")
# Build an ISO virtual machine image from Registry
[group('Build Virtual Machine Image')]
build-iso $target_image=(registry + "/" + image_name) $tag=default_tag: && (_build-bib target_image tag "iso" "iso/iso.toml")
# ==============================================================================
# REBUILD TARGETS (Lokaler Build via Containerfile + Image Builder)
# REBUILD TARGETS (Lokaler Build via Containerfile + Image Builder, nur ISO)
# ==============================================================================
# Rebuild a QCOW2 virtual machine image locally
[group('Build Virtual Machine Image')]
rebuild-qcow2 $target_image=("localhost/" + image_name) $tag=default_tag: && (_rebuild-bib target_image tag "qcow2" "iso/disk.toml")
# Rebuild a RAW virtual machine image locally
[group('Build Virtual Machine Image')]
rebuild-raw $target_image=("localhost/" + image_name) $tag=default_tag: && (_rebuild-bib target_image tag "raw" "iso/disk.toml")
# Rebuild an ISO virtual machine image locally
[group('Build Virtual Machine Image')]
rebuild-iso $target_image=("localhost/" + image_name) $tag=default_tag: && (_rebuild-bib target_image tag "iso" "iso/iso.toml")
# ==============================================================================
# TEST TARGETS (nur lokale Test-Disks, Image bleibt sauber)
# ==============================================================================
# Injiziert einen Test-User in ein gebautes Plattenabbild (qcow2/raw).
# Das Container-Image wird NICHT veraendert - nur die lokale Test-Disk.
# ISO braucht das nicht (Anaconda legt den User bei Installation an).
# Passwort: keine ':' und keine Shell-Sonderzeichen ($, `, !, \).
[group('Test')]
seed-testuser type="qcow2" user="test" password="test123":
#!/usr/bin/env bash
set -euo pipefail
if [[ "{{ type }}" == "iso" ]]; then
echo "FEHLER: Bei ISO den User im Anaconda-Installer anlegen, kein Seed noetig."
exit 1
fi
if [[ "{{ password }}" == *:* ]]; then
echo "FEHLER: Passwort darf kein ':' enthalten (chpasswd-Format)."
exit 1
fi
image_file="output/{{ type }}/disk.{{ type }}"
if [[ ! -f "${image_file}" ]]; then
echo "FEHLER: ${image_file} nicht gefunden. Erst 'just build-{{ type }} ...' ausfuehren."
exit 1
fi
if ! command -v virt-customize >/dev/null; then
echo "FEHLER: virt-customize fehlt. Installieren mit: sudo dnf install -y guestfs-tools"
exit 1
fi
echo "==> Injiziere Test-User '{{ user }}' in ${image_file} (nur Test-Disk)"
sudo virt-customize -a "${image_file}" \
--selinux-relabel \
--run-command "useradd -m -G wheel '{{ user }}' && echo '{{ user }}:{{ password }}' | chpasswd"
echo "==> Fertig. Login als '{{ user }}', sudo via wheel-Gruppe."
# ==============================================================================
# RUN TARGETS
# RUN TARGETS (nur ISO - kein qcow2/raw)
# ==============================================================================
# Run a virtual machine with the specified image type and configuration
@@ -278,14 +237,6 @@ _run-vm $target_image $tag $type $config:
(sleep 30 && xdg-open http://localhost:"$port") &
podman run "${run_args[@]}"
# Run a virtual machine from a QCOW2 image
[group('Run Virtual Machine')]
run-vm-qcow2 $target_image=(registry + "/" + image_name) $tag=default_tag: && (_run-vm target_image tag "qcow2" "iso/disk.toml")
# Run a virtual machine from a RAW image
[group('Run Virtual Machine')]
run-vm-raw $target_image=(registry + "/" + image_name) $tag=default_tag: && (_run-vm target_image tag "raw" "iso/disk.toml")
# Run a virtual machine from an ISO
[group('Run Virtual Machine')]
run-vm-iso $target_image=(registry + "/" + image_name) $tag=default_tag: && (_run-vm target_image tag "iso" "iso/iso.toml")