Hi,
I am trying to prep myself some VM templated based on cloud init.
I checked https://www.apalrd.net/posts/2023/pve_cloud/ and had success creating Ubuntu template manually.
Then I managed to use a script similar to the one from the blog to create a series of templates for Ubuntu & Debian systems.
But when I try to do it for Fedora I hit quite some issues... There is no network inside the created VM.
They don't get any IP, and cannot reach anything.
Also when logging I see
and calling nmcli also gives an error
Here is the script I used
I am trying to prep myself some VM templated based on cloud init.
I checked https://www.apalrd.net/posts/2023/pve_cloud/ and had success creating Ubuntu template manually.
Then I managed to use a script similar to the one from the blog to create a series of templates for Ubuntu & Debian systems.
But when I try to do it for Fedora I hit quite some issues... There is no network inside the created VM.
They don't get any IP, and cannot reach anything.
Also when logging I see
Bash:
Failed to connect to bus: Connection refused
and calling nmcli also gives an error
Bash:
$ nmcli device
Error: Could not create NMClient object: Could not connect: Connection refused.
Here is the script I used
Bash:
#!/bin/bash
# May need to install "libguestfs-tools " on proxmox host
function download_image() {
mkdir -p images
wget -nc -P images $1
}
#Create template
#args:
# 1: vm_id
# 2: vm_name
# 3: file name in the current directory
function create_template() {
if [[ "$force_recreate" != "true" ]] && qm status $1 &>/dev/null; then
echo "Template $2 ($1) exists, skipping..."
return
fi
echo "Deleting existing template $1"
qm destroy $1
echo "Creating template $2 ($1)"
qm create $1 --name $2 --ostype l26
echo "Customizing image $3"
virt-customize -a $3 --install qemu-guest-agent
virt-customize -a $3 --install avahi
#Set boot device & add cloud init disk
qm set $1 --scsi0 ${storage}:0,import-from="$(pwd)/$3",discard=on
qm set $1 --boot order=scsi0 --scsihw virtio-scsi-single
qm set $1 --agent enabled=1,fstrim_cloned_disks=1
qm set $1 --ide2 ${storage}:cloudinit
#Set networking to default bridge
qm set $1 --net0 virtio,bridge=vmbr0
qm set $1 --memory 4096 --cores 4 --cpu host
# qm set $1 --serial0 socket --vga default
qm set $1 --ipconfig0 "ip6=auto,ip=dhcp"
qm set $1 --ciuser ${username}
qm set $1 --sshkeys ${ssh_keyfile}
# Resize disk and finalize template
qm disk resize $1 scsi0 ${disk_size}
qm template $1
}
# Global Config
export ssh_keyfile=/etc/pve/priv/authorized_keys
export username=fedora
export storage=local-btrfs
export disk_size=32G
# export force_recreate=true
# Download Images
download_image https://gb.mirrors.cicku.me/fedora/linux/releases/41/Cloud/x86_64/images/Fedora-Cloud-Base-Generic-41-1.4.x86_64.qcow2
# Create Templates
create_template 920 "template-fedora-41" "images/Fedora-Cloud-Base-Generic-41-1.4.x86_64.qcow2"
Last edited: