Compare commits

..

3 Commits

Author SHA1 Message Date
Lukas Greve
2a529df043 add support for fedora 43 2025-11-18 16:56:44 +01:00
Lukas Greve
435ca041c0 add support for Fedora Cloud 43 2025-11-18 16:55:39 +01:00
Lukas Greve
f25c33eaca remove complex bit related to fedora rawhide 2025-11-18 16:55:24 +01:00
3 changed files with 25 additions and 66 deletions

View File

@@ -1,62 +1,5 @@
#!/bin/bash #!/bin/bash
# Function to get latest Fedora Rawhide image URL using a more reliable method
get_fedora_latest_rawhide_url() {
local base_url="https://dl.fedoraproject.org/pub/fedora/linux/development/rawhide/Cloud/x86_64/images/"
# Method: Try fetching the latest link from the directory
local temp_dir
temp_dir=$(mktemp -d)
# Download the HTML directory listing
if curl -s -o "$temp_dir/listing.html" "$base_url"; then
# Look for the most recent Fedora-Cloud-Base-Generic-Rawhide qcow2 file
local latest_file
latest_file=$(grep -i "Fedora-Cloud-Base-Generic-Rawhide.*\.qcow2" "$temp_dir/listing.html" | \
sort -r | head -1 | sed -E 's/.*href="([^"]*)".*/\1/')
if [[ -n "$latest_file" ]]; then
echo "${base_url}${latest_file}"
else
# If we can't find Fedora-Cloud-Base-Generic-Rawhide specifically,
# look for any Fedora image with a qcow2 extension
local any_file
any_file=$(grep -i "Fedora.*\.qcow2" "$temp_dir/listing.html" | \
head -1 | sed -E 's/.*href="([^"]*)".*/\1/')
if [[ -n "$any_file" ]]; then
echo "${base_url}${any_file}"
else
echo ""
fi
fi
else
# If network fails, return empty string to skip Fedora download
echo ""
fi
# Cleanup
rm -rf "$temp_dir"
}
# Function to check if a Fedora Rawhide image already exists in the target directory
check_fedora_rawhide_exists() {
local target_dir="$1"
# Look for any existing Fedora Rawhide image by pattern
if [[ -d "$target_dir" ]]; then
local exists
exists=$(find "$target_dir" -maxdepth 1 -type f -name "*Fedora-Cloud-Base-Generic-Rawhide*.qcow2" 2>/dev/null | head -1)
if [[ -n "$exists" ]]; then
echo "true"
else
echo "false"
fi
else
echo "false"
fi
}
# Image URLs with dynamic Fedora URL handling # Image URLs with dynamic Fedora URL handling
IMAGES=( IMAGES=(
"https://cloud.debian.org/images/cloud/trixie/latest/debian-13-genericcloud-amd64.raw" "https://cloud.debian.org/images/cloud/trixie/latest/debian-13-genericcloud-amd64.raw"
@@ -65,17 +8,9 @@ IMAGES=(
"https://dl.rockylinux.org/pub/rocky/10/images/x86_64/Rocky-10-GenericCloud-Base.latest.x86_64.qcow2" "https://dl.rockylinux.org/pub/rocky/10/images/x86_64/Rocky-10-GenericCloud-Base.latest.x86_64.qcow2"
"https://cloud-images.ubuntu.com/noble/current/noble-server-cloudimg-amd64.img" "https://cloud-images.ubuntu.com/noble/current/noble-server-cloudimg-amd64.img"
"https://cloud.centos.org/centos/10-stream/x86_64/images/CentOS-Stream-GenericCloud-x86_64-10-latest.x86_64.qcow2" "https://cloud.centos.org/centos/10-stream/x86_64/images/CentOS-Stream-GenericCloud-x86_64-10-latest.x86_64.qcow2"
"https://download.fedoraproject.org/pub/fedora/linux/releases/43/Cloud/x86_64/images/Fedora-Cloud-Base-Generic-43-1.6.x86_64.qcow2"
) )
# Add Fedora image if we can get a valid URL AND no Fedora Rawhide image exists
FEDORA_EXISTS=$(check_fedora_rawhide_exists "/var/lib/libvirt/images")
if [[ "$FEDORA_EXISTS" == "false" ]]; then
FEDORA_URL=$(get_fedora_latest_rawhide_url)
if [[ -n "$FEDORA_URL" ]]; then
IMAGES+=("$FEDORA_URL")
fi
fi
# Target directory # Target directory
TARGET_DIR="/var/lib/libvirt/images" TARGET_DIR="/var/lib/libvirt/images"

View File

@@ -0,0 +1,23 @@
terraform {
required_version = ">= 0.13"
required_providers {
libvirt = {
source = "dmacvicar/libvirt"
version = "0.8.3"
}
}
}
provider "libvirt" {
uri = "qemu+ssh://lukas@192.168.1.170/system"
}
module "shared_modules" {
source = "../../shared_modules"
vm_name = "f43-bios"
image_location = "https://download.fedoraproject.org/pub/fedora/linux/releases/43/Cloud/x86_64/images/Fedora-Cloud-Base-Generic-43-1.6.x86_64.qcow2"
ssh_key = "" # please provide a SSH public key
enable_cloudinit = true
# disk_size_bytes = 101474836480
}

View File

@@ -89,6 +89,7 @@ create_original_url_mapping() {
cat << 'EOF' cat << 'EOF'
noble-server-cloudimg-amd64.img=https://cloud-images.ubuntu.com/noble/current/noble-server-cloudimg-amd64.img noble-server-cloudimg-amd64.img=https://cloud-images.ubuntu.com/noble/current/noble-server-cloudimg-amd64.img
Fedora-Cloud-Base-Generic-42-1.1.x86_64.qcow2=https://download.fedoraproject.org/pub/fedora/linux/releases/42/Cloud/x86_64/images/Fedora-Cloud-Base-Generic-42-1.1.x86_64.qcow2 Fedora-Cloud-Base-Generic-42-1.1.x86_64.qcow2=https://download.fedoraproject.org/pub/fedora/linux/releases/42/Cloud/x86_64/images/Fedora-Cloud-Base-Generic-42-1.1.x86_64.qcow2
Fedora-Cloud-Base-Generic-43-1.6.x86_64.qcow2=https://download.fedoraproject.org/pub/fedora/linux/releases/43/Cloud/x86_64/images/Fedora-Cloud-Base-Generic-43-1.6.x86_64.qcow2
openSUSE-Tumbleweed-Minimal-VM.x86_64-Cloud.qcow2=https://download.opensuse.org/tumbleweed/appliances/openSUSE-Tumbleweed-Minimal-VM.x86_64-Cloud.qcow2 openSUSE-Tumbleweed-Minimal-VM.x86_64-Cloud.qcow2=https://download.opensuse.org/tumbleweed/appliances/openSUSE-Tumbleweed-Minimal-VM.x86_64-Cloud.qcow2
Rocky-10-GenericCloud-Base.latest.x86_64.qcow2=https://dl.rockylinux.org/pub/rocky/10/images/x86_64/Rocky-10-GenericCloud-Base.latest.x86_64.qcow2 Rocky-10-GenericCloud-Base.latest.x86_64.qcow2=https://dl.rockylinux.org/pub/rocky/10/images/x86_64/Rocky-10-GenericCloud-Base.latest.x86_64.qcow2
debian-13-genericcloud-amd64.raw=https://cloud.debian.org/images/cloud/trixie/latest/debian-13-genericcloud-amd64.raw debian-13-genericcloud-amd64.raw=https://cloud.debian.org/images/cloud/trixie/latest/debian-13-genericcloud-amd64.raw