25 lines
891 B
Bash
25 lines
891 B
Bash
# installing libguestfs-tools only required once, prior to first run
|
|
apt update -y
|
|
apt install libguestfs-tools -y
|
|
|
|
VMID=9004
|
|
|
|
IMAGE=jammy-server-cloudimg-amd64.img
|
|
# remove existing image in case last execution did not complete successfully
|
|
rm *-server-cloudimg-amd64.img
|
|
wget http://cloud-images.ubuntu.com/jammy/current/jammy-server-cloudimg-amd64.img
|
|
virt-customize -a $IMAGE --install ['qemu-guest-agent','rsyslog']
|
|
virt-customize -a $IMAGE --truncate /etc/machine-id
|
|
|
|
qm create 9004 --name "ubuntu-2204-cloudinit-template" --memory 2048 --cores 2 --net0 virtio,bridge=vmbr1
|
|
qm importdisk 9004 jammy-server-cloudimg-amd64.img local-ssd
|
|
qm set 9004 --scsihw virtio-scsi-pci --scsi0 local-ssd:vm-9004-disk-0
|
|
qm set 9004 --boot c --bootdisk scsi0
|
|
qm set 9004 --ide2 local-ssd:cloudinit
|
|
qm set 9004 --serial0 socket --vga serial0
|
|
qm set 9004 --agent enabled=1
|
|
|
|
qm template 9004
|
|
|
|
#rm $IMAGE
|